Route::middleware(['auth'])->group(function () { Route::get('/dashboard', 'DashboardController@index'); Route::get('/profile', 'ProfileController@index'); });
Route::prefix('admin')->group(function () { Route::get('/users', 'UserController@index'); Route::get('/orders', 'OrderController@index'); });
Route::middleware(['auth'])->prefix('admin')->group(function () { Route::get('/dashboard', 'DashboardController@index'); Route::get('/profile', 'ProfileController@index'); });In this example, we are defining both the 'auth' middleware and the prefix 'admin' to the group of routes '/dashboard' and '/profile'. In conclusion, the Illuminate\Routing\Router Group is a powerful tool for managing multiple routes under a single middleware or prefix. This package is a part of Laravel's routing library and helps in writing clean and maintainable code.