48 lines
899 B
PHP
48 lines
899 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class OAuthCode extends Model
|
|
{
|
|
protected $table = 'oauth_codes';
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $fillable = [
|
|
'id',
|
|
'client_id',
|
|
'user_id',
|
|
'code',
|
|
'code_challenge',
|
|
'state',
|
|
'redirect_uri',
|
|
'scope',
|
|
'expires_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'expires_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OAuthClient::class, 'client_id', 'client_id');
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isExpired(): bool
|
|
{
|
|
return $this->expires_at < now();
|
|
}
|
|
}
|