我一直在努力让Entrust按照这里的说明与Laravel 5合作https://github.com/Zizaco/entrust
我已根据要求进行了所有更改,添加了用户和角色(我没有添加权限,因为我不需要检查它们......只是角色),为用户分配角色以及何时尝试登录在用户中我收到此错误消息
参数1传递给 Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()必须是 Illuminate \ Contracts \ Auth \ Authenticatable的实例,实例 App \ User给出,调用 C:\ WWW \ procurement2 \厂商\ laravel \框架\ SRC \照亮\验证\ SessionGuard.php 在第385行并定义
我不知道这个错误意味着什么或如何解决它
以下是所有代码更改
应用/ user.php的
<?php
namespace App;
use Zizaco\Entrust\Traits\EntrustUserTrait;
use Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent
{
use EntrustUserTrait;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'firstname', 'lastname', 'email', 'password', 'userlevel', 'buyer'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
应用/ HTTP / Kernel.php
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
];
应用/配置/ app.php
'providers' => [
/*
* Laravel Framework Service Providers...
*/
...
/*
* Package Service Providers...
*/
Zizaco\Entrust\EntrustServiceProvider::class,
];
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
...
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
],
应用/配置/ auth.php
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users',
],
答案 0 :(得分:1)
App/User.php
应该Illuminate\Foundation\Auth\User
而不是use Illuminate\Database\Eloquent\Model as Eloquent;
。