diff --git a/app/Services/QualityDocumentService.php b/app/Services/QualityDocumentService.php index 66af795..313ada7 100644 --- a/app/Services/QualityDocumentService.php +++ b/app/Services/QualityDocumentService.php @@ -347,8 +347,9 @@ public function availableOrders(array $params): array $query = Order::where('tenant_id', $tenantId) ->whereNotIn('id', $linkedOrderIds) - ->with(['items']) - ->withCount('items'); + ->withCount(['nodes as location_count' => function ($q) { + $q->whereNull('parent_id'); + }]); if ($q !== '') { $query->where(function ($qq) use ($q) { @@ -364,8 +365,8 @@ public function availableOrders(array $params): array 'id' => $order->id, 'order_number' => $order->order_no, 'site_name' => $order->site_name ?? '', - 'delivery_date' => $order->delivery_date ?? '', - 'location_count' => $order->items_count, + 'delivery_date' => $order->delivery_date?->format('Y-m-d') ?? '', + 'location_count' => $order->location_count, ]) ->toArray(); }