Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Laravel

Grouping Routes in Laravel

Organize routes with prefixes, names, middleware groups, and controller groups.

Grouping Routes in Laravel — a practical guide to Laravel route groups with clear examples you can reuse in real projects.

Laravel Tutorial Series (20/27). Prefer one page? Read the complete Laravel tutorial (all 27 topics).

Short description

Route groups apply shared settings (prefix, name, middleware) to many routes at once.

Prefix + name group

Route::prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [AdminController::class, 'dashboard'])->name('dashboard');
    Route::resource('posts', AdminPostController::class);
});
// URLs: /admin/dashboard , names: admin.dashboard

Middleware group

Route::middleware(['auth', 'verified'])->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit']);
});

Controller group

Route::controller(PostController::class)->group(function () {
    Route::get('/posts', 'index');
    Route::post('/posts', 'store');
});

Leave a reply

Your email address will not be published. Required fields are marked *