首页 > 解决方案 > 在 laravel 5.6 中找不到 Trait 'App\HasRoles' 错误

问题描述

我正在尝试通过 laravel 5.6 角色权限系统

当我尝试使用默认身份验证(php artisan make:auth)注册时,我收到此错误

“Symfony \ Component \ Debug \ Exception \ FatalErrorException(E_UNKNOWN)特征'App \ HasRoles'未找到”

这是我的模型 user.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
    use HasRoles;

    protected $guard_name = 'web'; 

    /**
     * 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',
    ];
}

标签: phplaravelpermissionsroles

解决方案


运行此命令

作曲家安装


推荐阅读