If you have the following URLs:
/control-panel/{team_id}/
/control-panel/{team_id}/schedule
/control-panel/{team_id}/delete
etc...
(They all share the first part of the URL – /control-panel/{team_id}
)
Then you don’t have to write out the routes like this:
Route::get("control-panel/{team_id}","[email protected]");
Route::get("control-panel/{team_id}/schedule","[email protected]");
Route::delete("control-panel/{team_id}/delete","[email protected]");
Instead, you can group the routes and add a prefix:
Route::group(["prefix"=>"control-panel/{team_id}"], function() {
Route::get("/","[email protected]");
Route::get("schedule","[email protected]");
Route::delete("delete","[email protected]");
});
Putting a group within a group
You can also put a Route::group()
inside another one.
Route::group(["prefix"=>"control-panel/{team_id}"], function() {
Route::get("/","[email protected]");
Route::group(["prefix"=>"schedule"],function() {
Route::get("/","[email protected]");
Route::post("/add_new","[email protected]");
}
Route::delete("delete","[email protected]");
});