*/ use HasFactory, Notifiable, TwoFactorAuthenticatable, HasRoles; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'email_verified_at', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', 'app_authentication_secret', 'app_authentication_recovery_codes', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'app_authentication_secret' => 'encrypted', 'app_authentication_recovery_codes' => 'encrypted:array', 'has_email_authentication' => 'boolean', ]; } /** * Get the user's initials */ public function initials(): string { return Str::of($this->name) ->explode(' ') ->take(2) ->map(fn ($word) => Str::substr($word, 0, 1)) ->implode(''); } public function canAccessPanel(Panel $panel): bool { return $this->hasPermissionTo('manage panels'); } public function getAppAuthenticationSecret(): ?string { return $this->app_authentication_secret; } public function saveAppAuthenticationSecret(?string $secret): void { $this->app_authentication_secret = $secret; $this->save(); } public function getAppAuthenticationHolderName(): string { return $this->email; } public function getAppAuthenticationRecoveryCodes(): ?array { return $this->app_authentication_recovery_codes; } public function saveAppAuthenticationRecoveryCodes(?array $codes): void { $this->app_authentication_recovery_codes = $codes; $this->save(); } public function hasEmailAuthentication(): bool { return $this->has_email_authentication; } public function toggleEmailAuthentication(bool $condition): void { $this->has_email_authentication = $condition; $this->save(); } }