33 خطوط
895 B
PHP
33 خطوط
895 B
PHP
<?php
|
|
|
|
namespace App\Modules\Identity\Domain;
|
|
|
|
use App\Modules\Identity\Domain\Enums\UserRole;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserInvitation extends Model
|
|
{
|
|
use HasUlids;
|
|
|
|
protected $fillable = [
|
|
'organization_id', 'email', 'role', 'profile', 'token_hash', 'expires_at', 'invited_by',
|
|
'accepted_by', 'accepted_at', 'revoked_at',
|
|
];
|
|
|
|
protected $hidden = ['token_hash'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'role' => UserRole::class, 'profile' => 'array', 'expires_at' => 'immutable_datetime',
|
|
'accepted_at' => 'immutable_datetime', 'revoked_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
public function isUsable(): bool
|
|
{
|
|
return $this->accepted_at === null && $this->revoked_at === null && $this->expires_at->isFuture();
|
|
}
|
|
}
|