laravellaravel-5.5laravel-views

Laravel 5.5 How to read flash data in a view page


How can I print a enter image description here

My Controller is redirecting to this View with flash data(data from a table row). How do I print for example, just the "titulo" or "resumo"?

Or, instead of sending all the information from a table row to a single variable, do I have to send separately into different variables?

Thanks in advance.


Solution

  • This is the way you can send flash data from the backend:

    public function show (){
    
    //some code here
    
    return redirect('/')->with('flash', 'message here');
    }
    

    and in the view you can display it like this:

    {{session('flash')}} 
    

    The above will display "message here".

    If you have return redirect('/')->with('alert', 'something happened');

    {{session('alert')}} 
    

    The above will display "something happened".