'datetime', 'revoked_at' => 'datetime', 'last_validated_at' => 'datetime', ]; protected $appends = [ 'is_active', 'is_expired', ]; public function user() { return $this->belongsTo(User::class); } protected function isActive(): Attribute { return Attribute::make( get: fn () => !$this->is_expired && is_null($this->revoked_at), ); } protected function isExpired(): Attribute { return Attribute::make( get: fn () => $this->expires_at instanceof Carbon && $this->expires_at->isPast(), ); } public function scopeActive($query) { return $query ->whereNull('revoked_at') ->where('expires_at', '>', now()); } }