I've been trying to get Entrust working with Laravel 5 following the instruction here https://github.com/Zizaco/entrust
I've made all the changes as requested, added users and roles (I haven't added permissions as I won't need to check them...just roles), assigned roles to user and when I try to log in a user I get this error message
Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in C:\www\procurement2\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 385 and defined
I've no idea what this error means or how to fix it
Here is all the code changes
App/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',
];
}
App/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/config/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,
],
App/config/auth.php
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users',
],
App/User.php
should extend Illuminate\Foundation\Auth\User
instead of use Illuminate\Database\Eloquent\Model as Eloquent;
.