Reputation: 21
I create validation using laravel form request file and I want to set session in laravel request file and send the session with validation error to blade view.. can I do that ?
Thanks :)
Upvotes: 1
Views: 1747
Reputation: 106
Using Laravels validation whether that be within the App\Http\Requests
or in the controller itself using
$this->validate($request, [
'name' => 'required
]);
Will automatically return errors back to the view itself for you to display within the $errors
variable.
If you're calling the Validator::make()
method yourself and wish to check the errors manually and redirect. You can do this by using
$validator = Validator::make($request, [...]);
if($validator->fails()) {
return redirect()->back()->withErrors($validator->errors());
}
Upvotes: 3