sigd/app/Models/User.php

53 lines
1.1 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Notifications\ResetPassword;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable;
protected $fillable = [
'name', 'email', 'password', 'user_group_id', 'agency_id', 'active_status',
];
protected $hidden = [
'password', 'remember_token',
];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
}
public function userGroup()
{
return $this->belongsTo(UserGroup::class);
}
public function agency()
{
return $this->belongsTo(Agency::class);
}
public function getScope(): string
{
return $this->agency->scope ?? '';
}
}