Save a user’s last login timestamp and IP address in the users table.

Step 1 - Migration

Add too or create a new migration, similar to the following:

Schema::table('users', function (Blueprint $table) {

Step 2 - Model

Next, we need to add these fields as fillables in app/User.php model:

protected $fillable = [

Step 3 - Method

Open app/Http/Controllers/Auth/LoginController.php, and add the following method:

function authenticated(Request $request, $user)
        'last_login_at' => Carbon::now()->toDateTimeString(),
        'last_login_ip' => $request->getClientIp()

Add use statement

use Illuminate\Http\Request;


All done, now, your application will logged users' most recent IP & timestamps to database.