*/ use HasApiTokens, HasFactory, HasRoles, Notifiable, SoftDeletes; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'username', 'email', 'password', 'created_by', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', 'two_factor_secret', ]; public function twoFactorRecoveryCodes(): HasMany { return $this->hasMany(TwoFactorRecoveryCode::class); } /** * Route-model binding (and URLs) use the UUID, never the numeric PK. */ public function getRouteKeyName(): string { return 'public_id'; } protected static function booted(): void { static::creating(function (User $user) { $user->public_id ??= (string) Str::uuid(); }); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'two_factor_enabled' => 'boolean', 'two_factor_secret' => 'encrypted', 'two_factor_confirmed_at' => 'datetime', ]; } }