Edit File: OrderController.php
<?php namespace App\Http\Controllers\Admin; use App\Enums\OrderStatusEnum; use App\Services\Api\OrderService; use App\Http\Controllers\Controller; use App\Traits\OrderTrait; class OrderController extends Controller { use OrderTrait; public function __construct(private OrderService $orderService) {} public function index($status = null) { $orderStatus = $this->orderStatusesForUser($status); if (request()->ajax()) { $rows = $this->orderService->getOrderAccordingToStatusInDashboard($orderStatus); $html = view('admin.orders.table', ['rows' => $rows, 'status' => $status])->render(); return response()->json(['html' => $html]); } return view('admin.orders.index', ['status' => is_array($status) ? 'all' : $status]); } public function newOrders($status = 'new') { return $this->index($status); } public function currentOrders($status = 'current') { return $this->index($status); } public function finishedOrders($status = 'finished') { return $this->index($status); } public function cancelledOrders($status = 'cancelled') { return $this->index($status); } public function show($id) { $order = $this->orderService->detailsForDashboard($id); return view('admin.orders.show', compact('order')); } }
Back to File Manager