Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - Illegal offset type in AuthManager.php

Tags:

php

laravel

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',
     ],
],
like image 468
alyatek Avatar asked Aug 30 '25 17:08

alyatek


2 Answers

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
]);  

like image 173
AdiL IsmaiL Avatar answered Sep 02 '25 07:09

AdiL IsmaiL


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.

like image 22
Phuong Vu N. Avatar answered Sep 02 '25 06:09

Phuong Vu N.