Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| OrderController | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| sync | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers\Admin; |
| 4 | |
| 5 | use App\Http\Controllers\Concerns\ResolvesContext; |
| 6 | use App\Http\Controllers\Controller; |
| 7 | use App\Jobs\SyncNuvemshopOrdersJob; |
| 8 | use App\Models\Order; |
| 9 | use App\Models\StoreIntegration; |
| 10 | use Illuminate\Http\RedirectResponse; |
| 11 | use Illuminate\Http\Request; |
| 12 | use Illuminate\View\View; |
| 13 | |
| 14 | class OrderController extends Controller |
| 15 | { |
| 16 | use ResolvesContext; |
| 17 | |
| 18 | public function index(Request $request): View |
| 19 | { |
| 20 | $store = $this->currentStore(); |
| 21 | $orders = Order::query() |
| 22 | ->with('influencer', 'commission', 'items') |
| 23 | ->where('store_id', $store->id) |
| 24 | ->when($request->filled('status'), fn ($q) => $q->where('status', $request->string('status'))) |
| 25 | ->latest('placed_at') |
| 26 | ->paginate(20) |
| 27 | ->withQueryString(); |
| 28 | |
| 29 | return view('admin.orders.index', compact('orders')); |
| 30 | } |
| 31 | |
| 32 | public function sync(): RedirectResponse |
| 33 | { |
| 34 | $integration = StoreIntegration::query()->where('store_id', $this->currentStore()->id)->whereHas('provider', fn ($q) => $q->where('slug', 'nuvemshop'))->firstOrFail(); |
| 35 | SyncNuvemshopOrdersJob::dispatch($integration->id, now()->subDays(30)->toDateTimeString(), now()->toDateTimeString()); |
| 36 | |
| 37 | return back()->with('success', 'Sincronização enviada para a fila.'); |
| 38 | } |
| 39 | } |