*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'password', 'role', 'no_pekerja', 'jabatan', ]; /** * 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: isAdmin public function isAdmin(): bool { return $this->role === 'admin'; } // Helper: isStaff public function isStaff(): bool { return $this->role === 'staff'; } public function scopeSearch($query, $keyword) { return $query->where('name', 'like', "%$keyword%") ->orWhere('no_pekerja', 'like', "%$keyword%") ->orWhere('jabatan', 'like', "%$keyword%"); } public function surveys() { return $this->hasMany(Survey::class); } public function responses() { return $this->hasMany(Response::class); } }