Home » How to return view with flash message in Laravel 6?

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?

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

Read Also:  Laravel Bootstrap Alert (flash message) with Examples

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

Read Also:  JavaScript Dynamic Input Form Example

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 :

Read Also:  MySQL WHERE Clause with AND, OR, IN, NOT IN

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel Redirect Tutorial Example From Scratch
  2. Read Also:  PHP Laravel 6 Session-Based Flash Message Example
  3. Read Also:  Send, Get data redirect route with parameters in laravel
  4. Read Also:  How To Add Flash Messages in Laravel 6 Session?
  5. Read Also:  Laravel Update Multiple Records using Eloquent
  6. Read Also:  PHP Laravel 6 Flash Message Notification
  7. Read Also:  Angular 6 Routing Tutorial with Examples
  8. Read Also:  Laravel 6 display flash message on view
  9. Read Also:  Laravel 7 Implement Flash Messages with example
  10. Read Also:  PHP Get Folder Path From File Path Examples

Leave a Comment

Your email address will not be published. Required fields are marked *