2025-12-01 06:41:22 +07:00
|
|
|
<?php
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
2025-12-01 07:15:43 +07:00
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
2025-12-01 06:41:22 +07:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
2025-12-01 07:22:22 +07:00
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
2025-12-02 09:54:56 +07:00
|
|
|
use App\Models\Department;
|
|
|
|
|
use App\Models\AssetLocation;
|
2025-12-01 06:41:22 +07:00
|
|
|
|
|
|
|
|
class User extends Authenticatable
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
2025-12-01 07:22:22 +07:00
|
|
|
use HasFactory, Notifiable, HasUuids, HasRoles;
|
2025-12-01 06:41:22 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'name',
|
|
|
|
|
'email',
|
|
|
|
|
'password',
|
2025-12-02 09:54:56 +07:00
|
|
|
'department_id',
|
|
|
|
|
'asset_location_id',
|
|
|
|
|
'two_factor_enabled',
|
|
|
|
|
'two_factor_secret',
|
|
|
|
|
'two_factor_recovery_codes',
|
|
|
|
|
'two_factor_confirmed_at',
|
|
|
|
|
'last_active_at',
|
2025-12-01 06:41:22 +07:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be hidden for serialization.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $hidden = [
|
|
|
|
|
'password',
|
|
|
|
|
'remember_token',
|
2025-12-02 09:54:56 +07:00
|
|
|
'two_factor_secret',
|
|
|
|
|
'two_factor_recovery_codes',
|
2025-12-01 06:41:22 +07:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'email_verified_at' => 'datetime',
|
2025-12-01 07:15:43 +07:00
|
|
|
'password' => 'hashed',
|
2025-12-02 09:54:56 +07:00
|
|
|
'two_factor_confirmed_at' => 'datetime',
|
|
|
|
|
'two_factor_enabled' => 'boolean',
|
|
|
|
|
'two_factor_recovery_codes' => 'array',
|
|
|
|
|
'last_active_at' => 'datetime',
|
2025-12-01 06:41:22 +07:00
|
|
|
];
|
|
|
|
|
}
|
2025-12-02 09:54:56 +07:00
|
|
|
|
|
|
|
|
public function department()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Department::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function assetLocation()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(AssetLocation::class);
|
|
|
|
|
}
|
2025-12-01 06:41:22 +07:00
|
|
|
}
|