vd/app/Models/Account/Account.php
2018-11-06 16:07:41 +08:00

62 lines
1.4 KiB
PHP

<?php
namespace App\Models\Account;
use App\Core\Model;
use Illuminate\Auth\Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;
use App\Models\Permission\Traits\HasRoles;
use Dipper\Foundation\Nestedset\NodeTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
/**
* 账号
*/
class Account extends Model implements AuthenticatableContract, JWTSubject
{
use NodeTrait, SoftDeletes, HasRoles, Authenticatable;
protected $table = 'accounts';
protected $fillable = ['id', 'username', 'nickname', 'email', 'mobile', 'password', 'salt', 'status'];
public static function boot()
{
parent::boot();
static::saving(function ($model) {
unset($model['avatar']);
});
}
/**
* Get the hidden attributes for the model.
*
* @return array
*/
public function getHidden()
{
return [$this->getLftName(), $this->getRgtName(), 'password', 'salt', '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 [];
}
}