*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'is_admin', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } /** * Beziehung zu Nagellacken */ public function nailPolishes() { return $this->belongsToMany(NailPolish::class, 'user_nail_polishes', 'user_id', 'nail_polish_id'); } /** * Prüft, ob der User ein Admin ist */ public function isAdmin() { return $this->is_admin || in_array($this->email, ['admin@neonail.com', 'neueradmin@neonail.com']); } /** * Macht den User zum Admin */ public function makeAdmin() { $this->is_admin = true; $this->save(); } /** * Entfernt Admin-Rechte */ public function removeAdmin() { $this->is_admin = false; $this->save(); } }