There are many ways using which you can group your routes in Laravel right now. Consider the following group of routes. use Illuminate\Support\Facades\Route; Route::get('/', [BookController::class, 'index']); Route::get('/books/{id}', [BookController::class, 'show']); Route::get('/books/search/{search}', [BookController::class, 'search']); Route::post('/book', [BookController::class, 'store']); As you can tell, we have four routes to manage books and if you notice, all of these routes have one thing in common.
use Illuminate\Support\Facades\Route; use App\Http\Controllers\BookController; Route::controller(BookController::class)->group(function () { Route::get('/', 'index'); Route::get('/books/{id}', 'show'); Route::get('/books/search/{search}', 'search'); Route::post('/book', 'store'); }); As you can tell, by using this approach now you have all the routes, that use the same controller, are under the same group.
Now, if you’re grouping routes by controllers using the above approach and if you specify the controller on the route once again, it will override the group controller.