I want to save a log register in my table logs_users
when an user make the login successfully. For make this, logs_users table have the next fields:
+id
+user_id: Id of the user
+log_id :Number that represents the log( in this case, the number is 2)
+created_at
I dont understand how I can make this using the events in laravel 5.4 so if you can tell me the steps I will thank you
You can override authenticated
method in the Auth\LoginController
, something like:
protected function authenticated(Request $request, $user)
{
auth()->user()->logsUsers()->create();
}
I assume you already defined logsUsers()
relationship. If not, do that:
public function logsUsers()
{
return $this->hasMany(LogsUser::class);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments