Role::class, "employment_form" => EmploymentForm::class, "employment_date" => "date", ]; protected $hidden = [ "remember_token", ]; public function vacationLimits(): HasMany { return $this->hasMany(VacationLimit::class); } public function vacationRequests(): HasMany { return $this->hasMany(VacationRequest::class); } public function createdVacationRequests(): HasMany { return $this->hasMany(VacationRequest::class, "creator_id"); } public function vacations(): HasMany { return $this->hasMany(Vacation::class); } public function scopeSearch(Builder $query, ?string $text): Builder { if ($text === null) { return $query; } return $query ->where("first_name", "ILIKE", $text) ->orWhere("last_name", "ILIKE", $text) ->orWhere("email", "ILIKE", $text); } public function getAvatar(): string { $colors = config("colors"); return $this->getAvatarGenerator() ->backgroundColor($colors[strlen($this->fullname) % count($colors)]) ->image(); } public function getFullNameAttribute(): string { return "{$this->first_name} {$this->last_name}"; } public function hasRole(Role $role): bool { return $this->role === $role; } protected function getAvatarNameKey(): string { return "fullName"; } protected static function newFactory(): UserFactory { return UserFactory::new(); } }