Zaed_Abdullah/irrigation-report-api/app/Models/User.php
2024-12-31 11:48:55 +07:00

75 lines
1.5 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\Sanctum\HasApiTokens;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use App\Notifications\PasswordReset;
class User extends Authenticatable implements JWTSubject
{
use HasApiTokens, HasFactory, Notifiable, HasUuids;
protected $table = 'user.users';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'urole_id',
'username',
'email',
'password',
'fullname',
'avatar',
'phone',
'last_active',
'created_at',
'updated_at',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'password' => 'hashed',
];
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
public function role()
{
return $this->belongsTo(UserRole::class, 'urole_id');
}
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
}