diff --git a/app/Filament/Resources/PanelBoxValidationResource.php b/app/Filament/Resources/PanelBoxValidationResource.php index c1cfeb5..2d5b6b8 100644 --- a/app/Filament/Resources/PanelBoxValidationResource.php +++ b/app/Filament/Resources/PanelBoxValidationResource.php @@ -178,6 +178,8 @@ class PanelBoxValidationResource extends Resource ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { $pId = $get('line_id'); + $plantId = $get('plant_id'); + $plaCode = Plant::find($plantId)?->code; $set('part_validation_type', null); $set('show_validation_image', false); $set('validation1_image_url', null); @@ -384,7 +386,17 @@ class PanelBoxValidationResource extends Resource $set('item_id', null); return; } - } else { + else if($plantCode != $plaCode){ + Notification::make() + ->title('Invalid Plant Code') + ->body("Scanned plant code doesn't match the selected plant.") + ->danger() + ->send(); + $set('item_id', null); + return; + } + } + else { Notification::make() ->title('Invalid QR Format') @@ -478,6 +490,7 @@ class PanelBoxValidationResource extends Resource // $set('serial_number', null); // $set('serial_number', $serialNumber); } + // Check if user input matches the database values foreach ($partValidationColumns as $field) { if ($get("{$field}_visible")) {