1
0
forked from metin2/web
web/app/Models/Account.php

118 lines
2.4 KiB
PHP
Raw Normal View History

2023-07-23 01:14:14 +03:00
<?php
namespace App\Models;
use App\Models\Enums\AccountStatusEnum;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Contracts\Auth\MustVerifyEmail;
2023-07-23 01:14:14 +03:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2023-07-28 19:57:16 +03:00
use Illuminate\Foundation\Auth\User;
2023-07-23 01:14:14 +03:00
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class Account extends User implements MustVerifyEmail
2023-07-23 01:14:14 +03:00
{
use HasApiTokens, HasFactory, Notifiable;
2023-07-28 19:57:16 +03:00
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'account';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'account';
/**
* The name of the "created at" column.
*
* @var string|null
*/
2023-07-28 19:57:16 +03:00
const CREATED_AT = 'create_time';
/**
* The name of the "updated at" column.
*
* @var string|null
*/
const UPDATED_AT = null;
2023-07-23 01:14:14 +03:00
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
2023-07-28 19:57:16 +03:00
'login',
'email',
2023-07-23 01:14:14 +03:00
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
2023-07-28 19:57:16 +03:00
'social_id',
'securitycode'
2023-07-23 01:14:14 +03:00
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'status' => AccountStatusEnum::class
2023-07-23 01:14:14 +03:00
];
/**
* Determine if the user has verified their email address.
*
* @return bool
*/
public function hasVerifiedEmail(): bool
{
return $this->status != AccountStatusEnum::NOT_AVAILABLE;
}
/**
* Mark the given user's email as verified.
*
* @return bool
*/
public function markEmailAsVerified(): bool
{
return $this->forceFill([
'status' => AccountStatusEnum::OK,
])->save();
}
/**
* Send the email verification notification.
*
* @return void
*/
public function sendEmailVerificationNotification(): void
{
$this->notify(new VerifyEmail);
}
/**
* Get the email address that should be used for verification.
*
* @return string
*/
public function getEmailForVerification(): string
{
return $this->email;
}
2023-07-23 01:14:14 +03:00
}