laravel 6 route group code example
Example 1: group routes in laravel
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
});
Route::get('/user/profile', function () {
});
});
Example 2: named route with parameter laravel
Route::get('/menu/{category}/{product}/{item}', ['as' => 'named.route' , 'uses' => 'MenuController@listItem']);
route('named.route', ['category' => $category->id, 'product' => $product->id, 'item' => $item->id]);
Example 3: laravel group routes
Route::group(['prefix' => 'admin'], function () {
Route::get('users', function () {
});
});
Example 4: laravel route
Route::get('user/{id}', function ($id) {
return 'User '.$id;
});