Reputation: 692
I am using with()
helper to pass some error messages to views. My code for this is
redirect('somewhere')->with('message', 'show some message')
Then in the targeted view to catch the message I have this:
@if(count($errors)>0)
<div class="alert alert-success">
<ul >
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
But no message is delivered to the view. What's the problem here?
Upvotes: 0
Views: 57
Reputation: 3170
Please check this link Redirecting With Flashed Session Data
In targeted view you can handle message like this
@if (session('message'))
<div class="alert alert-success">
{{ session('message') }}
</div>
@endif
Upvotes: 1
Reputation: 3774
redirect('somewhere')->withErrors(['message', 'show some message'])
Upvotes: 1