From c6fd61a9ba2dc4d9aa25c1a9b4d4c537feb54571 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 25 Mar 2026 10:49:13 +0530 Subject: [PATCH] Updated item_id load functionality on resource page --- app/Filament/Resources/ProcessOrderResource.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ProcessOrderResource.php b/app/Filament/Resources/ProcessOrderResource.php index c269506..23836a4 100644 --- a/app/Filament/Resources/ProcessOrderResource.php +++ b/app/Filament/Resources/ProcessOrderResource.php @@ -9,6 +9,7 @@ use App\Models\Item; use App\Models\Line; use App\Models\Plant; use App\Models\ProcessOrder; +use App\Models\ProductCharacteristicsMaster; use Closure; use Filament\Facades\Filament; use Filament\Forms; @@ -130,11 +131,14 @@ class ProcessOrderResource extends Resource ->reactive() ->options(function (callable $get) { $plantId = $get('plant_id'); - if (empty($plantId)) { + $lineId = $get('line_id'); + if (empty($plantId) || empty($lineId)) { return []; } - return Item::where('plant_id', $plantId)->pluck('code', 'id'); + $availItems = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('item_id', 'item_id')->toArray(); + + return Item::where('plant_id', $plantId)->whereIn('id', $availItems)->pluck('code', 'id'); // return Item::where('plant_id', $plantId)->pluck('code', 'id'); }) ->disabled(fn (Get $get) => ! empty($get('id'))) ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {