diff --git a/app/Filament/Resources/ProductionPlanResource.php b/app/Filament/Resources/ProductionPlanResource.php index ab7b71c..8614515 100644 --- a/app/Filament/Resources/ProductionPlanResource.php +++ b/app/Filament/Resources/ProductionPlanResource.php @@ -154,17 +154,22 @@ class ProductionPlanResource extends Resource // $currentPath = url()->current(); // $currentPath = $_SERVER['REQUEST_URI']; // dd($currentPath); - $exists = ProductionPlan::where('plant_id', $get('plant_id')) + + $isUpdate = !empty($get('id')); + if (!$isUpdate) + { + $exists = ProductionPlan::where('plant_id', $get('plant_id')) ->where('shift_id', $get('shift_id')) ->where('line_id', $get('line_id')) ->whereDate('created_at', today()) ->exists(); - if ($exists) - { - $set('line_id', null); - $set('ppLineError', 'Production plan already updated.'); - return; + if ($exists) + { + $set('line_id', null); + $set('ppLineError', 'Production plan already updated.'); + return; + } } $set('ppLineError', null); } @@ -203,6 +208,9 @@ class ProductionPlanResource extends Resource ->label('Production Quantity') ->readOnly() ->default(0), + Forms\Components\TextInput::make('id') + ->hidden() + ->readOnly(), ]) ->columns(2), ]);