i'm quite new to laravel and i have a fairly simple question (I assume it is simple, could be wrong):
I have a column hasLoggedIn with a default value of TRUE and i would like to run a query as soon as the user is authenticated, so i can update my database without having to run this query on every page or every returned view.
Problem: I can't find where to put this query.
Any tip would be greatly appreciated!
Much love from Germany and I hope you guys get to have a great weekend! :)
Basically, you can write your logic to execute when users are authenticated in authenticated() method in LoginController if you are using 5.4
**
* The user has been authenticated.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function authenticated(Request $request, $user)
{
// i use this to flash a message when users are logged in
flash()->success("{$user->name}さんようこそ!!");
}
I think if you make a general Class with static method and call the method in your controller when you need it, or if you gonna used more than once in one controller than you can use __construct.