I've found good information on handling nested resource controllers and passing multiple constraints but seem to find nothing on this specific problem (probably cause I'm thinking about it all wrong!).
If I want to create the following in my API
- /cars (show all cars)
- /cars/1 (show carId = 1)
- /cars/1/performance (show performance for carId=1)
- /cars/1/performance/parts (show performance of parts for carId=1)
- /cars/1/performance/parts/1 (show performance of partId=1 for carId=1)
- /cars/performance (show performance of all cars)
- /cars/performance/parts
- /parts
- /parts/1 etc... (same for parts as cars above)
would I have to create routes and controllers for most of them in this fashion
Route::group(array('prefix' => 'myAwesomeCarApi'), function()
{
Route::resource('cars', 'CarsController');
Route::resource('cars/performance', 'CarsPerController');
Route::resource('cars/performance/parts', 'CarsPerPartsController');
Route::resource('cars.performance/parts', 'CarsPerPartsController');
Route::resource('parts', 'PartsController');
Route::resource('parts/performance', 'PartsPerController');
etc...
});
or is there some trickery I'm missing for creating dynamic controllers e.g only 3 (CarController, PartsController, PerformanceController) and handling the different routes in the code?