*/ use HasFactory, Notifiable; /** * @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); } /** * 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', ]; } }