*/ protected $fillable = [ 'name', 'email', 'password', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', 'two_factor_recovery_codes', 'two_factor_secret', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'role' => UserRole::class, ]; /** * The accessors to append to the model's array form. * * @var array */ protected $appends = [ 'profile_photo_url', ]; public function hasRole(string|UserRole $role): bool { if (is_string($role)) { $role = UserRole::tryFromName($role); // custom helper zie onder } return $this->role === $role; } }