Posts Learn Snippets Categories Tags About
/

Nested Route Group in Laravel

Learn how to define nested route group in Laravel and simplify your code.

Created on Jul 12, 2021

9 views

In Laravel you can nest route group, what that means is that you can create a group within a group. To achieve that you can define your route like below.
Route::group(['prefix' => 'hello'], function () {
    Route::group(['prefix' => 'world'], function () {
        Route::get('/', function () {
            return 'hello world';
        });
    });
});

So now you can access the route by entering "/hello/world" and get the "hello world" string back as response.

Created by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.