2026-08-18 12:03:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Infra\Database\Models;
|
|
|
|
|
|
|
|
|
|
use Database\Factories\ApiClientFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
|
use Infra\Casts\ClientIdentifierCast;
|
|
|
|
|
use Infra\Casts\ClientNameCast;
|
|
|
|
|
use Infra\Casts\ClientSecretCast;
|
|
|
|
|
use Infra\Casts\UuidCast;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @property \Ramsey\Uuid\UuidInterface $id
|
|
|
|
|
* @property \Application\Security\Models\ValueObjects\ClientName $name
|
2026-08-18 17:31:29 +02:00
|
|
|
* @property string $slug
|
2026-08-20 12:08:15 +02:00
|
|
|
* @property \Application\Security\Models\ValueObjects\ClientIdentifier $identifier ENCRYPTED, Unique identifier that should not change
|
|
|
|
|
* @property \Application\Security\Models\ValueObjects\ClientSecret $secret ENCRYPTED, api secret that can be regenerated
|
|
|
|
|
* @property bool $is_active Defines if the client can be used in order to gain access to the system
|
2026-08-18 12:03:29 +02:00
|
|
|
* @property \Illuminate\Support\Carbon $updated_at
|
|
|
|
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
|
|
|
|
*
|
|
|
|
|
* @method static \Database\Factories\ApiClientFactory factory($count = null, $state = [])
|
|
|
|
|
*
|
|
|
|
|
* @mixin \Eloquent
|
|
|
|
|
*/
|
|
|
|
|
final class ApiClient extends Authenticatable
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<ApiClientFactory> */
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
use HasUuids;
|
|
|
|
|
use Notifiable;
|
|
|
|
|
|
|
|
|
|
protected static function newFactory(): ApiClientFactory
|
|
|
|
|
{
|
|
|
|
|
return ApiClientFactory::new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected $table = 'api_clients';
|
|
|
|
|
|
2026-08-20 12:08:15 +02:00
|
|
|
public $timestamps = false;
|
2026-08-18 12:03:29 +02:00
|
|
|
|
|
|
|
|
/** @var list<string> */
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'id',
|
|
|
|
|
'name',
|
2026-08-18 17:31:29 +02:00
|
|
|
'slug',
|
2026-08-18 12:03:29 +02:00
|
|
|
'identifier',
|
|
|
|
|
'secret',
|
|
|
|
|
'is_active',
|
|
|
|
|
'updated_at',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/** @var list<string> */
|
|
|
|
|
protected $hidden = [
|
|
|
|
|
'secret',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/** @return array<string, string> */
|
|
|
|
|
#[\Override]
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'id' => UuidCast::class,
|
|
|
|
|
'name' => ClientNameCast::class,
|
|
|
|
|
'identifier' => ClientIdentifierCast::class,
|
|
|
|
|
'secret' => ClientSecretCast::class,
|
|
|
|
|
'is_active' => 'boolean',
|
|
|
|
|
'updated_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|