Route prefix with auth middleware in laravel

Created at 13-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 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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.