Show message with Flash in Laravel 5 when redirecting


I am trying to display a message (Notification) when creating a user using Flash (Laracast).

In my user controller I have the store function:

public function store(Request $request){

    $user = new User($request->all());
    $user->password = bcrypt($request->password);

    Flash::success("Se ha registrado el usuario ".$user->name." de manera exitosa!");

    return redirect()->route('admin.users.index');    

Then I added: @include('flash::message') in the body of my template.

When creating a user and executing the redirection, the message does not appear on the page /users (corresponding to the index)

If I use, return $this->index(); works perfectly for me but the URL does not change to /users as I expected.

I've tried putting a direct message in the controller index and it works fine. (That is not using redirection) Ex:

public function index(){
    $users = User::orderBy('id', 'DESC')->paginate(5);

    Flash::success("Mensaje de prueba");

    return view('admin.users.users')->with('users', $users);

Any help I could use.

asked by Jose Gratereaux 12.01.2016 в 04:16

1 answer


Remember that in Laravel 5, the flash messages are put to the session that makes the request, something kind:

//En tu controller
Session::flash('flash_message', 'Mensaje de prueba');
//aquí haces render o redirect a tu view

And in your view:


That way you can display your flash messages.

I recommend you visit laracasts, it is a great reference for those of us who are interested in the framework. The concrete video for this can be seen in the here .


answered by 12.01.2016 в 18:23