Reputation: 131
I am trying to work my way with this route:
user/1/post/10
and within the posts controller (inside the show function) i try to get the $id of the post but i get the user id (1).
routes:
Route::resource('users.posts', 'PostsController');
and here is my function within post controller:
public function show($id)
{
dd($id);//output 1
}
Upvotes: 0
Views: 160
Reputation: 146201
You may try this:
public function show($user_id, $post_id)
{
dd($post_id); // 10
}
Both parameters will be passed to child resource controller method (show
) and the first parameter is the parent id
and the second one is child id
.
Upvotes: 1