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);
$user->save();
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.