*/ use HasFactory; use Notifiable; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Indicate if the user is a super admin. */ public function isSuperAdmin(): bool { /** @var UserRole $role */ $role = $this->role; return $role === UserRole::SUPER_ADMIN; } /** * Indicate if the user is an admin. */ public function isAdmin(): bool { /** @var UserRole $role */ $role = $this->role; return $role === UserRole::ADMIN || $role === UserRole::SUPER_ADMIN; } /** * Get the associated social accounts. * * @return HasMany */ public function socialAccounts(): HasMany { return $this->hasMany(SocialAccount::class); } /** * Get the associated vaults. * * @return HasMany */ public function vaults(): HasMany { return $this->hasMany(Vault::class, 'created_by'); } /** * Get the collaborations that belongs to the user. * * @return BelongsToMany */ public function collaborations(): BelongsToMany { return $this->belongsToMany(Vault::class)->withPivot('accepted'); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'role' => UserRole::class, ]; } }