2017-08-02 1 views
1

私はLaravel 5.4におり、Zizaco Entrustを使用してアプリケーションのロールと権限を処理しています。ユーザーが、それは私にこのエラーそれぞれのロールでユーザーを取得しようとしましたが、クラス 'ロール'が返されません。

(1/1)FatalErrorExceptionを返し

クラスの

HasRelationships.php(ライン487)には見られないロール '

とここに私のクエリは

use App\User; //declare user model 

$customer = User::with('roles')->get(); 

と私のUserモデル

<?php 

namespace App; 

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

use Zizaco\Entrust\Traits\EntrustUserTrait; 

class User extends Authenticatable 
{ 
    use EntrustUserTrait; 
    use Notifiable; 

    /** 
    * The attributes that are mass assignable. 
    * 
    * @var array 
    */ 
    protected $fillable = [ 
     'username', 'email', 'password', 'real_password', 'first_name' 
    ]; 

    /** 
    * The attributes that should be hidden for arrays. 
    * 
    * @var array 
    */ 
    protected $hidden = [ 
     'password', 'remember_token', 'real_password' 
    ]; 

    public function roles() 
    { 
     return $this->belongsToMany('Role','assigned_roles'); 
    } 

} 

のロールモデル

<?php 

namespace App; 

use Zizaco\Entrust\EntrustRole; 

class Role extends EntrustRole 
{ 

} 

と委託の設定

<?php 

/** 
* This file is part of Entrust, 
* a role & permission management solution for Laravel. 
* 
* @license MIT 
* @package Zizaco\Entrust 
*/ 

return [ 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust Role Model 
    |-------------------------------------------------------------------------- 
    | 
    | This is the Role model used by Entrust to create correct relations. Update 
    | the role if it is in a different namespace. 
    | 
    */ 
    'role' => 'App\Role', 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust Roles Table 
    |-------------------------------------------------------------------------- 
    | 
    | This is the roles table used by Entrust to save roles to the database. 
    | 
    */ 
    'roles_table' => 'roles', 

    /* 
    |-------------------------------------------------------------------------- 
    | Application User Model 
    |-------------------------------------------------------------------------- 
    | 
    | This is the User model used by Entrust to create correct relations. 
    | Update the User if it is in a different namespace. 
    | 
    */ 
    'user' => 'App\User', 

    /* 
    |-------------------------------------------------------------------------- 
    | Application Users Table 
    |-------------------------------------------------------------------------- 
    | 
    | This is the users table used by the application to save users to the 
    | database. 
    | 
    */ 
    'users_table' => 'users', 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust Permission Model 
    |-------------------------------------------------------------------------- 
    | 
    | This is the Permission model used by Entrust to create correct relations. 
    | Update the permission if it is in a different namespace. 
    | 
    */ 
    'permission' => 'App\Permission', 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust Permissions Table 
    |-------------------------------------------------------------------------- 
    | 
    | This is the permissions table used by Entrust to save permissions to the 
    | database. 
    | 
    */ 
    'permissions_table' => 'permissions', 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust permission_role Table 
    |-------------------------------------------------------------------------- 
    | 
    | This is the permission_role table used by Entrust to save relationship 
    | between permissions and roles to the database. 
    | 
    */ 
    'permission_role_table' => 'permission_role', 

    /* 
    |-------------------------------------------------------------------------- 
    | Entrust role_user Table 
    |-------------------------------------------------------------------------- 
    | 
    | This is the role_user table used by Entrust to save assigned roles to the 
    | database. 
    | 
    */ 
    'role_user_table' => 'role_user', 


]; 

アンyのアイデア、助けてください?

答えて

0

パッケージの内容がcomposer.jsonであることを確認してください。

サービスプロバイダが登録されていることを確認します。

続いて、実行することにより、自動ロードクラスマップを再生成:

composer dump-autoload 
関連する問題