I try to make a default controller base on the Laravel Restful Controller, and I'm block with the index
method with Nested Resources
.
I have a route Route::resource('photos.comments', 'DefaultController');
and I need to get the photo_id
in my index
method. But so fare, I only get {photos}
.
public function index(Request $request)
{
// $request->route('photos) => {photos}
}
or
public function index(Request $request, $photosId)
{
// photosId => {photos}
}
What am I missing ?
Thanks
Apparently you're doing it right. What do you mean when you say you get
{photos}
? Is thephoto_id
in the URL? Likephotos/1/comments
?Here's how I do it and it works:
route.php
StuffController.php