diff --git a/app/Filament/Resources/LineResource/Pages/CreateLine.php b/app/Filament/Resources/LineResource/Pages/CreateLine.php index 864bc3864..fe33dbe69 100644 --- a/app/Filament/Resources/LineResource/Pages/CreateLine.php +++ b/app/Filament/Resources/LineResource/Pages/CreateLine.php @@ -5,6 +5,7 @@ namespace App\Filament\Resources\LineResource\Pages; use App\Filament\Resources\LineResource; use Filament\Actions; use Filament\Resources\Pages\CreateRecord; +use Illuminate\Validation\ValidationException; class CreateLine extends CreateRecord { @@ -14,4 +15,66 @@ class CreateLine extends CreateRecord { return $this->getResource()::getUrl('create'); } + + protected function beforeCreate(): void + { + $errors = []; + + if (!empty($this->data['lPlantError'])) { + $errors['lPlantError'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['lNameError'])) { + $errors['lNameError'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['lTypeError'])) { + $errors['lTypeError'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group1_id_error'])) { + $errors['work_group1_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group2_id_error'])) { + $errors['work_group2_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group3_id_error'])) { + $errors['work_group1_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group4_id_error'])) { + $errors['work_group4_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group5_id_error'])) { + $errors['work_group5_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group6_id_error'])) { + $errors['work_group6_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group7_id_error'])) { + $errors['work_group7_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group8_id_error'])) { + $errors['work_group8_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($this->data['work_group9_id_error'])) { + $errors['work_group9_id_error'] = ['Fix the errors before submitting.']; + } + + //..warranty + if (!empty($this->data['work_group10_id_error'])) { + $errors['work_group10_id_error'] = ['Fix the errors before submitting.']; + } + + if (!empty($errors)) { + throw ValidationException::withMessages($errors); + } + } }