token = Str::random(40); $token->user_id = $userId; $token->created_at = Carbon::now(); $token->last_activity_at = Carbon::now(); $token->lifetime_seconds = $lifetime; return $token; } public function touch() { $this->last_activity_at = Carbon::now(); return $this->save(); } /** * Define the relationship with the owner of this access token. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo(User::class); } }