Route Groups: Shared Rules
Route group: wraps several routes so they share the same middleware, address prefix, or name prefix, written once, applied to all of them.
Route::middleware('auth')->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index'])
->name('dashboard');
Route::get('/settings', [SettingController::class, 'edit'])
->name('settings.edit');
});
A new route that forgets to be wrapped in the right middleware group is an easy-to-miss security hole: a delete-data route meant only for admins becomes accessible to anyone who knows the address. Always check a new route's position before considering it done.