I suggest setting up authentication for logins and use authorization to determine what a logged in user can or cannot do.
https://laravel.com/docs/11.x/authorization
Do you have separate login pages? Sorry didn't totally understand the above.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey, I am stuck in Laravel 11.
I define my custom route in the bootstrap/app.php file
app.php code
function (Router $router) { $router->middleware('web') ->group(base_path('routes/web.php'));
$router->middleware('web')
->prefix('admin')
->group(base_path('routes/admin.php'));
$router->middleware('web')
->prefix('vendor')
->group(base_path('routes/vendor.php'));
},
Admin.php route file code Route::group(['prefix' => 'auth'], function () { Route::get('login', [AuthController::class, 'index']); Route::post('login', [AuthController::class, 'login'])->name('admin.login');
Route::post('logout', [AuthController::class, 'logout'])->name('admin.logout');
});
Route::group(['middleware' => 'auth:admin'], function () { Route::prefix('dashboard')->group(function () { Route::get('index', [DashboardController::class, 'index'])->name('admin.dashboard'); });
}
I want the unauthorized access dashboard route to automatically redirect on the login route. How do I do this type of thing in Laravel 11?
@shivam7414 This Link will help you. Official Laravel 11 docs
Please or to participate in this conversation.