From 0801b84d7e77941b84c68d7692c9252eddcae43a Mon Sep 17 00:00:00 2001 From: Teon54 Date: Sun, 4 Aug 2024 13:00:25 +0330 Subject: [PATCH] Task 8. Customize Validation Messages. Done --- app/Http/Controllers/BuildingController.php | 2 +- app/Http/Requests/StoreBuildingRequest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BuildingController.php b/app/Http/Controllers/BuildingController.php index 9c752ab8..875b4cbb 100644 --- a/app/Http/Controllers/BuildingController.php +++ b/app/Http/Controllers/BuildingController.php @@ -17,7 +17,7 @@ public function create() // TASK: Customize the validation error message to say "Please enter the name" public function store(StoreBuildingRequest $request) { - Building::create($validator->validated()); + Building::create($request->validated()); return 'Success'; } diff --git a/app/Http/Requests/StoreBuildingRequest.php b/app/Http/Requests/StoreBuildingRequest.php index fbd8c064..4b969cf4 100644 --- a/app/Http/Requests/StoreBuildingRequest.php +++ b/app/Http/Requests/StoreBuildingRequest.php @@ -30,4 +30,11 @@ public function rules() 'name' => 'required' ]; } + + public function messages() + { + return [ + 'name' => 'Please enter the name', + ]; + } }