*/ use HasFactory, HasUuids; protected $fillable = [ 'account_id', 'invited_by', 'email', 'role', 'workspaces', 'accepted_at', ]; protected function casts(): array { return [ 'role' => WorkspaceRole::class, 'workspaces' => 'array', 'accepted_at' => 'datetime', ]; } public function account(): BelongsTo { return $this->belongsTo(Account::class); } public function invitedBy(): BelongsTo { return $this->belongsTo(User::class, 'invited_by'); } /** * `id` is a native Postgres uuid column — find() on a non-UUID string * raises a type-cast error rather than returning null. */ public static function fromId(?string $id): ?self { if (! $id || ! Str::isUuid($id)) { return null; } return self::find($id); } }