*/ protected $fillable = [ 'name', 'email', 'password', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var array */ 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', ]; } /** * ========== RELASI KONTRAKAN ========== */ /** * Relasi: 1 Admin punya banyak Kontrakan */ public function kontrakans() { return $this->hasMany(Kontrakan::class); } /** * Helper: Cek apakah admin adalah super_admin */ public function isSuperAdmin() { return $this->role === 'super_admin'; } /** * Helper: Cek apakah admin adalah admin biasa */ public function isAdmin() { return $this->role === 'admin'; } /** * Helper: Label human-readable untuk role admin. */ public function getRoleLabel() { return $this->role === 'super_admin' ? 'Super Admin' : 'Admin'; } }