Files
backend_vib360_laravel/app/Models/User.php
2025-03-27 18:54:06 +05:30

90 lines
1.9 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
protected $primaryKey = 'id'; // Make sure this matches your table's PK
public $incrementing = false; // UUIDs are not auto-incrementing
protected $keyType = 'string'; // Ensures UUIDs work properly
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
public function getJWTIdentifier()
{
// return $this->getKey();
return (string) $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
/**
* The attributes that are mass assignable.
*
* @var list<string>
*
*/
protected $fillable = [
'id',
'email',
'authority',
'name',
'tenant_id',
'customer_id',
'first_name',
'last_name',
'phone',
'description',
'created_time',
'version'
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function assets()
{
return $this->hasManyThrough(Asset::class, UserAssetLink::class, 'user_id', 'id', 'id', 'asset_id');
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id');
}
}