How to return view with flash message in Laravel 6?

Today, We want to share with you How to return view with flash message in Laravel 6?.In this post we will show you Implement Flash Message with Laravel 6.2,, hear for Laravel 6 Implement Flash Messages with example we will give you demo and example for implement.In this post, we will learn about Laravel 6.0 Show flash error and success messages in different ways with an example.

How to return view with flash message in Laravel 6?

Also Read This πŸ‘‰   PHP Laravel 6 Flash Message Notification

There are the Following The simple About print session message in laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to use alert box in laravel 6 controller?, so the Inlining flash messages with the redirect() call in Laravel 6 is used for this example is following below.

print session message in laravel

in laravel Controller

return view('member-datalist.standardUser.includes.members')->with('members', $members)->with('successMsg','Team is updated .');

blade view files

@if(!empty($successMsg))
  <div class="alert alert-success"> {{ $successMsg }}</div>
@endif

flash message in controller laravel 6

how to show error message in laravel blade

store functions in Laravel Controller

public function store(PostRequest $request) {
    if (Member::create($request->all())) {
        $request->session()->flash('activities.level', 'success');
        $request->session()->flash('activities.content', 'Member was successfully added!');
    } else {
        $request->session()->flash('activities.level', 'danger');
        $request->session()->flash('activities.content', 'Error!');
    }
    return redirect('/');
}

In your blade file:

@if(session()->has('activities.level'))
    <div class="alert alert-{{ session('activities.level') }}"> 
    {!! session('activities.content') !!}
    </div>
@endif

How to use alert box in laravel controller 6?

controller

return redirect()->back() ->with('success', 'Member Updated!');

 <script>
    var msg = '{{Session::get('success')}}';
    var check = '{{Session::has('success')}}';
    if(check){
      alert(msg);
    }
  </script>

Web Programming Tutorials Example with Demo

Read :

Also Read This πŸ‘‰   Display Image Preview Before Upload Multiple Images using jQuery,Ajax And PHP

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel redirect with success message.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.