MIF_E31232094/app/Models/User.php

54 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
protected $fillable = [
'name',
'email',
'password',
'role',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
// ── Helper role ───────────────────────────────────────────────
public function isAdmin(): bool
{
return $this->role === 'admin';
}
public function isUser(): bool
{
return $this->role === 'user';
}
// ── Relasi ───────────────────────────────────────────────────
public function notifications()
{
return $this->hasMany(Notification::class);
}
public function diagnoses()
{
return $this->hasMany(Diagnosis::class);
}
}