56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\CMS\Helpers\Gravatar;
|
|
use Illuminate\Auth\Authenticatable;
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
|
|
|
/**
|
|
* Class User
|
|
*/
|
|
class User extends Model implements AuthenticableInterface
|
|
{
|
|
use SoftDeletes, Authenticatable, Authorizable;
|
|
public $timestamps = true;
|
|
protected $fillable = [
|
|
'email',
|
|
'username',
|
|
'password',
|
|
'name',
|
|
];
|
|
protected $guarded = [];
|
|
/**
|
|
* The attributes excluded from the model's JSON form.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
const STATE_DELETED = 'deleted';
|
|
const STATE_BLOCKED = 'blocked';
|
|
const STATE_ACTIVE = 'active';
|
|
const ROLE_VISITOR = 'visitor';
|
|
const ROLE_EDITOR = 'editor';
|
|
const ROLE_ADMIN = 'admin';
|
|
|
|
/**
|
|
* Getter for Gravatar URL
|
|
*
|
|
* This method returns full path (url) to user's Gravatar. It accepts optional parameter for setting size.
|
|
*
|
|
* @param int $size size of rendered gravatar
|
|
*
|
|
* @return string
|
|
*/
|
|
public function gravatar($size = 50)
|
|
{
|
|
return Gravatar::img($this->email, $size);
|
|
}
|
|
}
|