TIFNJK_E41222887/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;
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use HasFactory, Notifiable, TwoFactorAuthenticatable;
protected $fillable = [
'name',
'email',
'password',
'role',
'employee_id',
];
protected $hidden = [
'password',
'two_factor_secret',
'two_factor_recovery_codes',
'remember_token',
];
public function employee()
{
return $this->hasOne(Employee::class);
}
// employee_id di kolom users untuk relasi One-to-One langsung
public function employeeProfile()
{
return $this->belongsTo(Employee::class, 'employee_id');
}
public function hasRole($role)
{
return $this->role === $role;
}
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'two_factor_confirmed_at'=> 'datetime',
];
}
}