Files
Sistem_Kehadiran_Taklimat_SPR/app/Models/User.php
2026-07-04 14:45:16 +08:00

64 lines
1.6 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Sppm\Dun;
use App\Notifications\ResetKataLaluanNotification;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
#[Fillable(['name', 'email', 'password', 'role', 'dun_id'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
public function isAdmin(): bool
{
return $this->role === 'admin';
}
public function isPengurus(): bool
{
return $this->role === 'pengurus';
}
public function isKaunter(): bool
{
return $this->role === 'kaunter';
}
public function dun(): BelongsTo
{
return $this->belongsTo(Dun::class, 'dun_id');
}
/**
* Guna e-mel dalam Bahasa Melayu untuk pautan set semula kata laluan.
*/
public function sendPasswordResetNotification(#[\SensitiveParameter] $token): void
{
$this->notify(new ResetKataLaluanNotification($token));
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}