*/ use HasFactory, HasRoles, Notifiable, SoftDeletes; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'konto_id', 'gender', 'name', 'email', 'password', 'app_verified_at', 'konto_title', 'konto_gender', 'konto_first_name', 'konto_last_name', 'konto_company', 'konto_email', 'konto_address', 'konto_location', 'konto_plz', 'konto_country', 'konto_phone', 'konto_uid_number', 'konto_agb_akzeptiert', ]; /** * 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_verified_at' => 'datetime', 'app_authentication_secret' => 'encrypted', 'app_authentication_recovery_codes' => 'encrypted:array', 'has_email_authentication' => 'boolean', ]; } protected static function booted(): void { static::addGlobalScope(new KontoScope); static::creating(function (User $user) { if (isset($user->konto_title)) { $konto = Konto::create([ 'konto_title' => $user->konto_title, 'konto_gender' => $user->konto_gender, 'konto_company' => $user->konto_company, 'konto_uid_number' => $user->konto_uid_number, 'konto_location' => $user->konto_location, 'konto_plz' => $user->konto_plz, 'konto_agb_akzeptiert' => $user->konto_agb_akzeptiert, 'konto_country' => $user->konto_country, 'konto_address' => $user->konto_address, 'konto_first_name' => $user->konto_first_name, 'konto_last_name' => $user->konto_last_name, 'konto_email' => $user->konto_email, 'konto_phone' => $user->konto_phone, ]); $user->konto_id = $konto->id; unset($user->konto_title); unset($user->konto_gender); unset($user->konto_company); unset($user->konto_uid_number); unset($user->konto_location); unset($user->konto_plz); unset($user->konto_agb_akzeptiert); unset($user->konto_country); unset($user->konto_address); unset($user->konto_first_name); unset($user->konto_last_name); unset($user->konto_email); unset($user->konto_phone); } $user->app_verified_at = now(); $user->email_verified_at = now(); $user->assignRole('gutachter'); }); } public function getAppAuthenticationSecret(): ?string { // This method should return the user's saved app authentication secret. return $this->app_authentication_secret; } public function saveAppAuthenticationSecret(?string $secret): void { // This method should save the user's app authentication secret. $this->app_authentication_secret = $secret; $this->save(); } public function getAppAuthenticationHolderName(): string { // In a user's authentication app, each account can be represented by a "holder name". // If the user has multiple accounts in your app, it might be a good idea to use // their email address as then they are still uniquely identifiable. return $this->email; } /** * @return ?array */ public function getAppAuthenticationRecoveryCodes(): ?array { // This method should return the user's saved app authentication recovery codes. return $this->app_authentication_recovery_codes; } /** * @param array | null $codes */ public function saveAppAuthenticationRecoveryCodes(?array $codes): void { // This method should save the user's app authentication recovery codes. $this->app_authentication_recovery_codes = $codes; $this->save(); } public function hasEmailAuthentication(): bool { // This method should return true if the user has enabled email authentication. return $this->has_email_authentication; } public function toggleEmailAuthentication(bool $condition): void { // This method should save whether or not the user has enabled email authentication. $this->has_email_authentication = $condition; $this->save(); } public function canAccessPanel(Panel $panel): bool { return true; } public function canAccessAdminPanel(Panel $panel): bool { if ($panel->getId() === 'admin') { return $this->hasVerifiedEmail(); } return false; } }