TarikAli's avatar

get user in multi guards same route

Hello, i have these routes

Route::group([
        'prefix' => LaravelLocalization::setLocale(), 
        'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']
    ],
    function () {
        Route::group([
            'prefix' => 'shared', 
            'as' => 'shared.',
            'middleware' => ['auth:admin,teacher'],
        ], function () {

            Route::prefix('options')->name('options.')->group(function () {
                Route::resource('', OptionController::class)->parameters(['' => 'option']);
                
            });
        }); 
});

when i loged in in the same browser it tow tabs one admin and the other teacher and

@dd(auth()->guard('admin')->check(), auth()->guard('teacher')->check())

the tow gives true

i want to get the options accordding to admin or teacher

0 likes
4 replies
Snapey's avatar

best practice - don't use multiple guards

1 like
TarikAli's avatar

ok, what's you opinion to use one guard for dashboard and one route for dashboard then admin and teacher and ...., enter dashboard using roles and permissions also make tow tables (admins, teachers) and linked morph with users table

Please or to participate in this conversation.