*/ use HasFactory, Notifiable; /** * The column defaults, so a user made in this request has them too. * * @var array */ protected $attributes = [ 'locale' => 'fi', ]; /** * @return BelongsTo */ public function supervisor(): BelongsTo { return $this->belongsTo(User::class, 'supervisor_id'); } /** * @return HasOne */ public function moneyPermissions(): HasOne { return $this->hasOne(UserMoneyPermissionsModel::class); } /** * Whether the user may see the given kind of money amounts: admins and * management always, employees and interns with a personal permission. */ public function canSeeMoney(MoneyPermission $permission): bool { if ($this->role->seesAllMoney()) { return true; } return $this->role->hasPersonalMoneyPermissions() && ($this->moneyPermissions?->allows($permission) ?? false); } /** * The language of the user's emails, such as the set-password link. */ public function preferredLocale(): string { return $this->locale->value; } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'role' => Role::class, 'is_active' => 'boolean', 'employment_ends_on' => 'date', 'locale' => Locale::class, ]; } }