$scopes * @property bool $revoked * @property Carbon|null $reminder_sent_at * @property Carbon|null $expired_info_sent_at * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property Carbon|null $expires_at * @property-read Client|null $client * @property-read User|null $user * * @method Builder isApiToken(bool $isApiToken = true) */ class Token extends PassportToken { /** @use HasFactory */ use HasFactory; /** * Get the client that the token belongs to. * * @return BelongsTo */ // @phpstan-ignore method.childReturnType public function client(): BelongsTo { return $this->belongsTo(Client::class, 'client_id', 'id'); } /** * Get the user that the token belongs to. * * @deprecated Will be removed in a future Laravel version. * * @return BelongsTo */ // @phpstan-ignore method.childReturnType public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'scopes' => 'array', 'revoked' => 'bool', 'expires_at' => 'datetime', 'reminder_sent_at' => 'datetime', 'expired_info_sent_at' => 'datetime', ]; } /** * @param Builder $query * @return Builder */ public function scopeIsApiToken(Builder $query, bool $isApiToken = true): Builder { if ($isApiToken) { return $query->whereHas('client', function (Builder $query): void { /** @var Builder $query */ $query->whereJsonContains('grant_types', 'personal_access'); }); } else { return $query->whereHas('client', function (Builder $query): void { /** @var Builder $query */ $query->whereJsonDoesntContain('grant_types', 'personal_access'); }); } } }