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) {