parseDataTableQuery($request); return Inertia::render('admin/manage/orders/Index', [ 'orders' => $this->orderService->paginateForIndex($tableQuery, $request->user()), 'filters' => $this->dataTableFilters($tableQuery), ]); } public function create(): Response { return Inertia::render('admin/manage/orders/Create', [ 'customers' => $this->orderService->customerOptions(), 'catalog' => $this->orderService->catalogItems(), 'channels' => OrderChannel::selectOptions(), 'storePriceTypes' => $this->orderService->storePriceTypeOptions(), ]); } public function store(OrderRequest $request): RedirectResponse { $this->orderService->create($request->validated(), $request->user()); Inertia::flash('success', 'Pesanan berhasil ditambahkan.'); return redirect()->route('admin.manage.orders.index'); } public function edit(Order $order): Response|RedirectResponse { if (! $order->status->isEditable()) { Inertia::flash('error', 'Pesanan tidak dapat diubah.'); return redirect()->route('admin.manage.orders.index'); } return Inertia::render('admin/manage/orders/Edit', [ 'order' => $this->orderService->findForEdit($order), 'customers' => $this->orderService->customerOptions(), 'catalog' => $this->orderService->catalogItems($order), 'channels' => OrderChannel::selectOptions(), 'storePriceTypes' => $this->orderService->storePriceTypeOptions(), ]); } public function update(OrderRequest $request, Order $order): RedirectResponse { $this->orderService->update($order, $request->validated()); Inertia::flash('success', 'Pesanan berhasil diperbarui.'); return redirect()->route('admin.manage.orders.index'); } public function destroy(Order $order): RedirectResponse { $this->orderService->delete($order); Inertia::flash('success', 'Pesanan berhasil dihapus.'); return redirect()->route('admin.manage.orders.index'); } public function transitionStatus(OrderStatusTransitionRequest $request, Order $order): RedirectResponse { $status = OrderStatus::from($request->validated('status')); $this->orderService->transitionStatus($order, $status); $message = match ($status) { OrderStatus::PROCESSING => 'Pesanan berhasil dikirim.', OrderStatus::COMPLETED => 'Pesanan berhasil diselesaikan.', OrderStatus::CANCELLED => 'Pesanan berhasil dibatalkan.', default => 'Status pesanan berhasil diperbarui.', }; Inertia::flash('success', $message); return redirect()->route('admin.manage.orders.index'); } }