mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
153 lines
5.1 KiB
PHP
153 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\UserFactory;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
use Illuminate\Notifications\DatabaseNotification;
|
|
use Illuminate\Notifications\DatabaseNotificationCollection;
|
|
use Illuminate\Support\Carbon;
|
|
use Spatie\Activitylog\Models\Activity;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
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;
|
|
|
|
/**
|
|
* App\Models\User
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $email
|
|
* @property string $password
|
|
* @property int $type
|
|
* @property int $status
|
|
* @property string|null $remember_token
|
|
* @property string|null $active_at
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property Carbon|null $deleted_at
|
|
* @property-read Collection|Activity[] $activities
|
|
* @property-read int|null $activities_count
|
|
* @property-read Model|\Eloquent $causer
|
|
* @property-read Collection|CompanyModule[] $companyModule
|
|
* @property-read int|null $company_module_count
|
|
* @property-read Collection|Contact[] $contacts
|
|
* @property-read int|null $contacts_count
|
|
* @property-read Collection|UserEmailVerification[] $emailVerification
|
|
* @property-read int|null $email_verification_count
|
|
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
|
|
* @property-read int|null $notifications_count
|
|
* @property-read Collection|PasswordReset[] $passwordReset
|
|
* @property-read int|null $password_reset_count
|
|
* @property-read Collection|Permission[] $permissions
|
|
* @property-read int|null $permissions_count
|
|
* @property-read Collection|Remark[] $remarks
|
|
* @property-read int|null $remarks_count
|
|
* @property-read Collection|Role[] $roles
|
|
* @property-read int|null $roles_count
|
|
* @property-read Model|\Eloquent $subject
|
|
* @property-read Model|\Eloquent $target
|
|
* @method static UserFactory factory(...$parameters)
|
|
* @method static Builder|User newModelQuery()
|
|
* @method static Builder|User newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|User onlyTrashed()
|
|
* @method static Builder|User permission($permissions)
|
|
* @method static Builder|User query()
|
|
* @method static Builder|User role($roles, $guard = null)
|
|
* @method static Builder|User whereActiveAt($value)
|
|
* @method static Builder|User whereCreatedAt($value)
|
|
* @method static Builder|User whereDeletedAt($value)
|
|
* @method static Builder|User whereEmail($value)
|
|
* @method static Builder|User whereId($value)
|
|
* @method static Builder|User whereName($value)
|
|
* @method static Builder|User wherePassword($value)
|
|
* @method static Builder|User whereRememberToken($value)
|
|
* @method static Builder|User whereStatus($value)
|
|
* @method static Builder|User whereType($value)
|
|
* @method static Builder|User whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|User withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|User withoutTrashed()
|
|
* @mixin \Eloquent
|
|
*/
|
|
class User extends AbstractModel implements
|
|
JWTSubject,
|
|
AuthenticatableContract,
|
|
AuthorizableContract,
|
|
CanResetPasswordContract
|
|
{
|
|
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes, HasFactory;
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* 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');
|
|
}
|
|
}
|