sifangpay/app/Models/Admin.php

47 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use App\Classc\SearchScopeTrait;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
class Admin extends Authenticatable
{
//
use SearchScopeTrait;
use HasRoles, Notifiable;
protected $fillable = [
'account', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function setPasswordAttribute($password) {
if($password)
{
$this->attributes['password'] = bcrypt($password);
}
}
protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
if (method_exists($model, 'isForceDeleting') && ! $model->isForceDeleting()) {
return;
}
$model->roles()->detach();
});
}
}