erp/app/Models/User.php

52 lines
1.0 KiB
PHP
Raw Normal View History

2022-07-23 17:07:13 +08:00
<?php
namespace App\Models;
2022-07-23 17:07:13 +08:00
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
2022-07-27 19:06:16 +08:00
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Traits\HasRoles;
2022-07-23 17:07:13 +08:00
class User extends Authenticatable
{
use Notifiable;
2022-07-27 19:06:16 +08:00
use HasRoles;
2022-07-23 17:07:13 +08:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'api_token', 'email_verified_at',
2022-07-23 17:07:13 +08:00
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
2022-07-27 19:06:16 +08:00
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value);
}
2022-08-04 18:13:00 +08:00
public function isRoot()
{
return $this->name === 'erpAdmin';
}
2022-07-23 17:07:13 +08:00
}