*/ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; /** * The accessors to append to the model's array form. * * @var array */ protected $appends = [ 'profile_photo_url', ]; public function canAccessPanel(Panel $panel): bool { if ($panel->getId() === 'user' && is_demo_environment()) { return false; } return true; } public function getTenants(Panel $panel): array | Collection { return $this->allCompanies(); } public function canAccessTenant(Model $tenant): bool { return $this->belongsToCompany($tenant); } public function getDefaultTenant(Panel $panel): ?Model { return $this->personalCompany(); } public function getFilamentAvatarUrl(): string { return $this->profile_photo_url; } public function contacts(): MorphMany { return $this->morphMany(Contact::class, 'contactable'); } public function managerOf(): HasMany { return $this->hasMany(Department::class, 'manager_id'); } public function switchCompany(mixed $company): bool { if (! $this->belongsToCompany($company)) { return false; } $this->forceFill([ 'current_company_id' => $company->id, ])->save(); $this->setRelation('currentCompany', $company); session(['current_company_id' => $company->id]); return true; } }