Laravel Redirect Back with() Message
Try
return Redirect::back()->withErrors(['msg' => 'The Message']);
and inside your view call this
@if($errors->any())
<h4>{{$errors->first()}}</h4>
@endif
Laravel 5 and later
Controller
return redirect()->back()->with('success', 'your message,here');
Blade:
@if (\Session::has('success'))
<div class="alert alert-success">
<ul>
<li>{!! \Session::get('success') !!}</li>
</ul>
</div>
@endif
Alternative approach would be
Controller
use Session;
Session::flash('message', "Special message goes here");
return Redirect::back();
View
@if (Session::has('message'))
<div class="alert alert-info">{{ Session::get('message') }}</div>
@endif
In Laravel 5.4 the following worked for me:
return back()->withErrors(['field_name' => ['Your custom message here.']]);
You have an error (misspelling):
Sessions::get('msg')// an extra 's' on end
Should be:
Session::get('msg')
I think, now it should work, it does for me.