How to return view with flash message?
It looks like you're mixing two different ways of passing data to a view, which I'm guessing is the problem. The documentation seems to indicate it's a one or the other type situation. You also seem to be mixing up view()->with()
and redirect()->with()
, which work differently. Try this:
return view('protected.standardUser.includes.documents')->with('documents', $documents)->with('successMsg','Property is updated .');
And
@if(!empty($successMsg)) <div class="alert alert-success"> {{ $successMsg }}</div>@endif
I order to use session stored flash messages, need to use following code into route method
.
$request->session()->flash('successMsg','Saved succesfully!');
and then do
@if(Session::has('successMsg')) <div class="alert alert-success"> {{ Session::get('successMsg') }}</div> @endif
that's it
I'm new in Laravel and I was facing the same issue... I just tried as below::
\Session::flash('flash','Message info');
And it works!!