55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\OauthClientFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class OauthClient extends Model
|
|
{
|
|
/** @use HasFactory<OauthClientFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'logo_url',
|
|
'client_id',
|
|
'client_secret_hash',
|
|
'redirect_uris',
|
|
'allowed_userinfo_fields',
|
|
'userinfo_claim_remap',
|
|
'is_confidential',
|
|
'is_active',
|
|
];
|
|
|
|
public function scopes(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(OauthScope::class, 'oauth_client_scope', 'client_id', 'scope_id')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function consents(): HasMany
|
|
{
|
|
return $this->hasMany(OauthConsent::class, 'client_id');
|
|
}
|
|
|
|
public function authorizations(): HasMany
|
|
{
|
|
return $this->hasMany(OauthAuthorization::class, 'client_id');
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'redirect_uris' => 'array',
|
|
'allowed_userinfo_fields' => 'array',
|
|
'userinfo_claim_remap' => 'array',
|
|
'is_confidential' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
}
|