Laravel multiple user DB tables, models and guards - user resources not showing in the Nova admin panel

69 Views Asked by At

I have separated basic users from admins - basic users are in the "clients" table and admins in the "users" table. I'm using Laravel Nova 4 as an admin panel.

My auth.php config looks like this:

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'clients',
    ],


    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'clients',
        ],
        'nova' => [
            'driver' => 'session',
            'provider' => 'admins',
        ]
    ],


    'providers' => [
        'clients' => [
            'driver' => 'eloquent',
            'model' => \App\Models\Client\Client::class,
        ],
        'admins' => [
            'driver' => 'eloquent',
            'model' => \App\Models\User::class,
        ],
    ],


    'passwords' => [
        'clients' => [
            'provider' => 'clients',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'admins' => [
            'provider' => 'admins',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],

];

Everything seems to be working fine, only admin users may log into the Nova admin panel, basic clients have their own login/profile on the website etc.

But the problem is that I see neither Client (basic user) nor User (admins) resources in the Nova sidebar. I can see every other resource but not these 2.

My nova.php config looks like this:

return [


    'license_key' => env('NOVA_LICENSE_KEY'),

    'name' => env('NOVA_APP_NAME', env('APP_NAME')),    

    'domain' => env('NOVA_DOMAIN_NAME', null),  
      
    'path' => '/nova',   

    'guard' => env('NOVA_GUARD', null),

    'passwords' => env('NOVA_PASSWORDS', null),

    'middleware' => [
        'web',
        HandleInertiaRequests::class,
        DispatchServingNovaEvent::class,
        BootTools::class,
    ],

    'api_middleware' => [
        'nova',
        Authenticate::class,
        Authorize::class,
    ],

    'pagination' => 'simple',

    'storage_disk' => env('NOVA_STORAGE_DISK', 'public'),

    'currency' => 'USD',

    'actions' => [
        'resource' => ActionResource::class,
    ],

    'impersonation' => [
        'started' => '/',
        'stopped' => '/',
    ],

];

In the .env file I have declared both NOVA_GUARD and NOVA_PASSWORDS to be "nova".

Does anyone have an idea how to force showing both User and Client resources in the admin panel?

0

There are 0 best solutions below