*/ use HasFactory, Notifiable, SoftDeletes, HasApiTokens; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'role', 'phone', ]; /** * 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', ]; } /** * Helper function untuk cek apakah user adalah Super Admin * * @return bool */ public function isSuperAdmin() { return $this->role === 'super_admin'; } /** * Helper function untuk cek apakah user adalah Admin biasa * * @return bool */ public function isAdmin() { return $this->role === 'admin'; } /** * Helper function untuk cek apakah user adalah User biasa * * @return bool */ public function isUser() { return $this->role === 'user'; } /** * Helper function untuk cek role * * @return bool */ public function hasRole($role) { return $this->role === $role; } /** * Relationship ke ActivityLog */ public function activityLogs() { return $this->hasMany(ActivityLog::class); } }