ensureCrmSubscription(); $scope = CustomerMaintenanceScopeService::forCurrentUser(); $workOrders = $scope->workOrderQuery() ->with(['equipment:id,name,code', 'assignedTechnician:id,first_name,last_name', 'project:id,name']) ->orderByDesc('created_at') ->paginate(20); return view('portal::customer.work_orders.index', compact('workOrders')); } public function show($id) { $this->ensureCrmSubscription(); $scope = CustomerMaintenanceScopeService::forCurrentUser(); if (! $scope->ownsWorkOrder((int) $id)) { abort(404); } $workOrder = $scope->workOrderQuery() ->with([ 'equipment', 'project', 'productionLine', 'preventiveSchedule', 'assignedTechnician:id,first_name,last_name', 'requester:id,first_name,last_name', ]) ->findOrFail($id); return view('portal::customer.work_orders.show', compact('workOrder')); } }