I am looking to add a flash message on successful login in Laravel 5.2. I have placed into a couple of places and had mild success but my last attempt resulted in the flash occurring even if the login was not successful.
Any ideas on the best place to add "\Session::flash('message','You have been logged in.');" during the login process?
depends purhaps you have a header/footer partial that is only included within authorised pages, and not included with in your log in page or fail etc something like that, that why its a generic flash message container , and will then be used to pick up any flash messages set?
Thanks for the reply simondavies. I have a partial set up already that displays the message if one exists and this partial is included in my layouts page The question I have is how to setup the message during the login process when there is a successful login attempt.
Thanks Snapey. I will give it a try. BTW, is this documented anywhere that I should have known? Or just a gem that you discovered? Are there other functions that can be added to AuthController that are automatically called?
it's not documented to my knowledge but if you examine the file AuthenticatesUsers.php , Taylor has slipped in things like this where the login process checks for the existence of a method and if so, calls it.
So oddly enough, I added the method to the AuthController.php file and it worked as expected. That said, I do not have an AuthenticatesUsers.php file in my vendor/laravel/framework/auth directory. Perhaps it exists elsewhere?