2025-11-06 17:09:52 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
2025-12-05 17:16:02 +05:30
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
2025-11-06 17:09:52 +05:30
|
|
|
|
|
|
|
|
class Admin extends Authenticatable
|
|
|
|
|
{
|
2025-12-05 17:16:02 +05:30
|
|
|
use HasFactory, Notifiable, HasRoles;
|
2025-11-06 17:09:52 +05:30
|
|
|
|
2025-12-05 17:16:02 +05:30
|
|
|
protected $guard_name = 'admin';
|
2025-11-06 17:09:52 +05:30
|
|
|
|
|
|
|
|
protected $fillable = [
|
2025-12-05 17:16:02 +05:30
|
|
|
'name', 'email', 'password', 'username',
|
|
|
|
|
'phone', 'emergency_phone', 'address',
|
|
|
|
|
'role', 'department', 'designation', 'joining_date',
|
2025-12-19 16:08:34 +05:30
|
|
|
'status', 'additional_info', 'type','employee_id', // admin/staff indicator
|
2025-11-06 17:09:52 +05:30
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $hidden = [
|
|
|
|
|
'password', 'remember_token',
|
|
|
|
|
];
|
2025-12-05 17:16:02 +05:30
|
|
|
|
|
|
|
|
public function setPasswordAttribute($value)
|
|
|
|
|
{
|
|
|
|
|
if (!$value) return;
|
|
|
|
|
|
|
|
|
|
if (Hash::needsRehash($value)) {
|
|
|
|
|
$this->attributes['password'] = Hash::make($value);
|
|
|
|
|
} else {
|
|
|
|
|
$this->attributes['password'] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDisplayNameAttribute()
|
|
|
|
|
{
|
|
|
|
|
return "{$this->name}";
|
|
|
|
|
}
|
2025-11-06 17:09:52 +05:30
|
|
|
}
|