64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Notifications\ResetPasswordNotification;
|
|
use Illuminate\Auth\Authenticatable;
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
|
use Illuminate\Contracts\Auth\CanResetPassword;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
/**
|
|
* Class User
|
|
*/
|
|
class User extends Model implements AuthenticableInterface, CanResetPassword
|
|
{
|
|
use SoftDeletes, Authenticatable, Authorizable, Notifiable;
|
|
const STATE_DELETED = 'deleted';
|
|
const STATE_BLOCKED = 'blocked';
|
|
const STATE_ACTIVE = 'active';
|
|
const ROLE_VISITOR = 'visitor';
|
|
const ROLE_EDITOR = 'editor';
|
|
const ROLE_ADMIN = 'admin';
|
|
public $timestamps = true;
|
|
protected $fillable = [
|
|
'email',
|
|
'username',
|
|
'password',
|
|
'name',
|
|
'role'
|
|
];
|
|
/**
|
|
* The attributes excluded from the model's JSON form.
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Get the e-mail address where password reset links are sent.
|
|
* @return string
|
|
*/
|
|
public function getEmailForPasswordReset()
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
/**
|
|
* Send the password reset notification.
|
|
*
|
|
* @param string $token
|
|
*
|
|
* @return void
|
|
*/
|
|
public function sendPasswordResetNotification($token)
|
|
{
|
|
$this->notify(new ResetPasswordNotification($token));
|
|
}
|
|
}
|