Reputation: 2651
I am creating an API route where some endpoints have ids in the route. I was hoping to do something like the following route but I'm not sure how to get the parameter when in the Resource Controller
Route::resource('plans','api\PlanController');
Route::resource('plans/{plan_id}/days','api\PlanDayController');
Is this possible, and if so how would I best make sure the Resource Controller filters the data to the correct plan_id as specified in the route? I would like to continue using the Route::resource
as this forces consistent structure into the API
Upvotes: 1
Views: 2032
Reputation: 50561
This is nested resource routing, still exists, just not in the docs anymore.
Route::resource('plans.days', 'api\PlanDayController');
GET plans/{plan}/days
GET plans/{plan}/days/{day}
etc...
Laravel Docs 5.1 - Nested Resources
Upvotes: 2