insertGetId($userdata); } protected $fillable = [ 'email', 'password', ]; protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; /** * Set permissions guard to API by default * @var string */ protected $guard_name = 'api'; /** * @inheritdoc */ public function getJWTIdentifier() { return $this->getKey(); } /** * @inheritdoc */ public function getJWTCustomClaims() { return []; } /** * @return bool * 验证是否管理员 */ public function isAdmin(): bool { foreach ($this->roles as $role) { if ($role->isAdmin()) { return true; } } return false; } }