The second method is the "old" method. I would use the modern one
Route::prefix('admin')->middleware(['first', 'second'])->group(function () {
Route::get('/orders/{id}', 'show');
Route::post('/orders', 'store');
});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
There are a few options to group routes:
Route::middleware(['first', 'second'])->group(function () {
or
Route::group(['middleware' => 'some_middleware']), (function () {
And then I also want to add the prefix:
Route::prefix('admin')->group(function () {
So what would be the preferred way to both have middleware and prefix on a group of routes? For example these 2:
Route::get('/orders/{id}', 'show');
Route::post('/orders', 'store');
The second method is the "old" method. I would use the modern one
Route::prefix('admin')->middleware(['first', 'second'])->group(function () {
Route::get('/orders/{id}', 'show');
Route::post('/orders', 'store');
});
Please or to participate in this conversation.