I am using Jetstream Starter Pack for User Authentication.
I have created a table for tracking user activities in the site.
migration -
Schema::create('users_sessions', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned()->nullable();
$table->string('user_email')->nullable();
$table->string('user_ip_address', 45)->nullable();
$table->string('login_status')->nullable();
$table->string('user_agent', 2048)->nullable();
$table->timestamps();
});
I want to update the login_status based on authentication, if user logged in, it will create a new row with 'logged in' and other informations.
insert logic when login -
Auth::login($newUser);
DB::table('users_sessions')->insert([
'user_id' => $newUser->id,
'user_email' => $newUser->email,
'user_ip_address' => request()->ip(),
'login_status' => 'logged in',
'user_agent' => request()->header('User-Agent'),
'created_at' => now(),
'updated_at' => now(),
]);
Now, when user logged out, i want to update the same row like that -
$user = DB::find($newUser->id);
DB::table('users_sessions')
->where('user_id', $user)
->update([
'login_status' => 'inactive',
'updated_at' => now(),
]);
But i can't find the login, logout method boot mechanism in the laravel jetstream, when it will run when boot those two methods. I can't find them in the docs either. Can anyone help?