*/ protected $fillable = [ 'name', 'email', 'password', 'nokp', 'alamat', 'notelefon', 'bangsa', 'jantina', 'is_admin_lesen_penjaja', 'is_admin_lesen_anjing', 'is_admin_lesen_perniagaan', 'avatar_path' ]; /** * 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', ]; } public function syarikats() { return $this->belongsToMany(Syarikat::class, 'user_syarikats', 'user_id', 'syarikat_id'); } public function polisi(){ return $this->hasMany(UserPolicies::class); } public function hasRole(string|array $role): bool { if (is_array($role)) { return in_array($this->role, $role); } return $this->role === $role; } public function short_bangsa(){ if(in_array($this->bangsa, ['melayu','cina','india'])){ $kod = strtoupper(substr($this->bangsa, 0, 1)); } else{ $kod = 'L'; } return $kod; } public function short_jantina(){ $kod = strtoupper(substr($this->jantina, 0, 1)); return $kod; } }