I'm trying to use middleware in the laravel routes but when I use the auth middleware the following error shows: https://i.sstatic.net/z6KGb.png
in my web.php i have
Route::get('/','Pages\GenericPagesController@get_index')->middleware('auth');
in config/auth.php i had to uncomment the providers -> users section because my table name is different than the usual users
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'users' => [
'driver' => 'database',
'table' => 'users',
],
],
For people who came here for a solution for lumen :
uncomment the following in bootstrap/app.php
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class
]);
I think you need to comment the
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
The providers
now is an array that has the values with same key
. If you don't use the eloquent
you can comment it or just rename it. Hope this can help. By the way, you might want to check whether your default guard
is web
or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With