I have two tables with a many to many relation. Groups and Members table with a pivot table group_member. The relations are well done and have seeded the tables including the pivot table. Now what i want to do is, when i select a group in the drop down, the list of members in that particular group should show up in a different drop box.
Controller
//displays the form
public function create()
{
$groups = Group::all()->where('user_id',Auth::user()->id);
$members = Member::with('groups')->get();
$selectedGroup = $groups->pluck('id')->toArray();
return view('group.show',compact('groups','selectedGroup','members'));
}
Now my code shows the groups alright but it doesn't fetch only the members belonging to that group but all members belonging to the user. How can i dynamically do this; Select a group and display its members at the same time. Thank you
group.showview. - Camilo