You need second layer (level) of grouping, first group by city, then by orders/products:
Route::prefix('{city}')->group(function() {
Route::prefix('products')->name('products')->controller(ProductController::class)->group(function () {
Route::post('/', 'getProducts')->name('.list');
// ...
});
Route::prefix('orders')->name('orders')->controller(OrderController::class)->group(function () {
Route::get('/create', 'create')->name('.create');
// ...
});
});
Having typed variable $city in controllers allows you to handle it in URLs (I have simple string type, you probably would have model type like YourCityModel):
class ProductController extends Controller
{
public function createProduct(Request $request, string $city)
{
dd(__CLASS__ . ' | ' . __FUNCTION__ . ' | ' . $city);
}
}
class OrderController extends Controller
{
public function create(Request $request, string $city)
{
dd(__CLASS__ . ' | ' . __FUNCTION__ . ' | ' . $city);
}
}
// http://127.0.0.1:8000/london/orders/create
"App\Http\Controllers\OrderController | create | london"
// http://127.0.0.1:8000/paris/products/create
"App\Http\Controllers\ProductController | createProduct | paris"
You may have any levels of grouping, for example to have URL /{client}/{city}/{action}/, just set another group of group of group of routes.