37 lines
662 B
PHP
37 lines
662 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class AuthToken extends Model
|
|
{
|
|
protected $table = 'auth_tokens';
|
|
|
|
protected $fillable = [
|
|
'client_id',
|
|
'token',
|
|
'expires_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'expires_at' => 'datetime',
|
|
];
|
|
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Client::class);
|
|
}
|
|
|
|
public function isValid(): bool
|
|
{
|
|
if ($this->expires_at === null) {
|
|
return true;
|
|
}
|
|
|
|
return $this->expires_at->isFuture();
|
|
}
|
|
}
|