Route prefix with auth middleware in laravel

Updated at 12-Jul-2021, By samar

Route prefix with auth middleware in laravel

In this session, we will try our hand at solving the "Route prefix with auth middleware in laravel".

This code snippet will add the common prefix to the specified URLs including auth middleware to your web routes.
  • Route prefix with admin using auth middleware in laravel

    --PATH routes\web.php
    Route::group(['prefix' => 'admin','middleware' => ['auth']], function() {
        Route::get('dashboard', [App\Http\Controllers\AdminController::class, 'index']);
    });
    

    This code snippet will generate the URLs with prefix domain.com/admin/ using auth middleware which means if you are not authenticated then you will be not able to visit the specified URLs.

Back to code snippet queries related laravel