*/ protected $fillable = [ 'nama', 'username', 'email', 'password', 'alamat', 'no_telp', 'tipe_pengguna', 'role' ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'tipe_pengguna' => 'string' ]; /** * Relasi ke model Sewa */ public function sewas() { return $this->hasMany(Sewa::class); } /** * Relasi ke model Chat sebagai pengirim */ public function sentChats() { return $this->hasMany(Chat::class, 'sender_id'); } /** * Relasi ke model Chat untuk menghitung pesan yang belum dibaca */ public function chats() { return $this->hasMany(Chat::class, 'sender_id'); } /** * Mengecek apakah user adalah admin */ public function isAdmin() { return $this->tipe_pengguna === 'admin'; } }