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.

Answers 1
  • 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']);
    });
    
    0

    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