Aceconhielo Aceconhielo - 3 years ago 147
PHP Question

Laravel 5.4 Save last login in logs table

I want to save a log register in my table

when an user make the login successfully. For make this, logs_users table have the next fields:

+user_id: Id of the user
+log_id :Number that represents the log( in this case, the number is 2)

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

Answer Source

You can override authenticated method in the Auth\LoginController, something like:

protected function authenticated(Request $request, $user)

I assume you already defined logsUsers() relationship. If not, do that:

public function logsUsers()
    return $this->hasMany(LogsUser::class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download