mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 20:44:01 +00:00
85 lines
2.2 KiB
PHP
85 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Auth\Authenticatable;
|
|
use Illuminate\Auth\MustVerifyEmail;
|
|
use Illuminate\Auth\Passwords\CanResetPassword;
|
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
|
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
|
|
|
class User extends AbstractModel implements
|
|
JWTSubject,
|
|
AuthenticatableContract,
|
|
AuthorizableContract,
|
|
CanResetPasswordContract
|
|
{
|
|
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
|
|
|
|
|
|
/**
|
|
* Get the identifier that will be stored in the subject claim of the JWT.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getJWTIdentifier()
|
|
{
|
|
return $this->getKey();
|
|
}
|
|
|
|
/**
|
|
* Return a key value array, containing any custom claims to be added to the JWT.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getJWTCustomClaims()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function emailVerification(): HasMany {
|
|
return $this->hasMany(UserEmailVerification::class, 'email', 'email');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function passwordReset(): HasMany {
|
|
return $this->hasMany(PasswordReset::class, 'user_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return belongsToMany
|
|
*/
|
|
public function companyModule(): belongsToMany
|
|
{
|
|
return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'company_module_id');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function contacts(): morphMany
|
|
{
|
|
return $this->morphMany(Contact::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function remarks(): morphMany
|
|
{
|
|
return $this->morphMany(Remark::class, 'owner');
|
|
}
|
|
}
|