Reputation: 541
public function store(Request $request)
{
//this method will be called when we signup for members
$this->validate($request, [
'title' => 'required|max:255',
'body' => 'required',
]);
return 'success';
}
this will automatically redirected to homepage of Laravel without any exception
i need a validation message there
eg. title is required
Upvotes: 0
Views: 43
Reputation: 62278
Laravel has performed the redirect and stored the errors in the session. It is up to you to modify your view to display the errors that have been put in the session.
You can read more about displaying validation errors in the documentation here.
Code example from that link: (add this to your view)
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
Upvotes: 1