Hello guys,
I have created 2 guards all using the JWT driver. One for called users and another called tutors. I am using Laravel 5.3. Authentication works perfectly with the users middleware when I declare it in my route like this and I am able to access protected routes using the token returned through authentication:
Route::group([
'middleware' => 'auth:api',
], function () {
//user protected routes go here
});
This is how I have declared the tutor middleware route:
Route::group([
'middleware' => 'auth:tutor',
], function () {
//tutor protected routes go here
});
When I use the tutor guard, authentication works perfectly and a token is returned to me, but anytime I try to use the token to make a request to a protected route, I get this error message:
ErrorException in CreatesUserProviders.php line 65:
Undefined index: model
in CreatesUserProviders.php line 65
at HandleExceptions->handleError('8', 'Undefined index: model', '/home/vagrant/code/studiens/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php', '65', array('config' => array('driver' => 'eloquent', 'table' => 'App\Tutor'))) in CreatesUserProviders.php line 65
at AuthManager->createEloquentProvider(array('driver' => 'eloquent', 'table' => 'App\Tutor')) in CreatesUserProviders.php line 38
at AuthManager->createUserProvider('tutors') in AbstractServiceProvider.php line 79
at AbstractServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application), 'tutor', array('driver' => 'jwt', 'provider' => 'tutors')) in AuthManager.php line 111
What am i doing wrong?
Thanks in advance.
U should check your guard in config/auth.php check the provider which is use for the table. here example
for Model 'administrators' => [
'driver' => 'eloquent',
'model' => App\Administrator::class,
],
for table not use a model
'administrators' => [
'driver' => 'database',
'table' => 'administrator',
],
I hope its help
Thank you so much @hafizu97 You saved my life 馃榾
cool, u saved my time @hafizu97
Most helpful comment
U should check your guard in config/auth.php check the provider which is use for the table. here example
for Model
'administrators' => [ 'driver' => 'eloquent', 'model' => App\Administrator::class, ],for table not use a model
'administrators' => [ 'driver' => 'database', 'table' => 'administrator', ],I hope its help