title: Get Values Based On Selected Value in Drop Down - Laravel
body: <p>I have two tables with a many to many relation. <code>Groups and Members table</code> with a pivot table <code>group_member</code>. 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.  </p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>//displays the form
  public function create()
      {
          $groups = Group::all()-&gt;where('user_id',Auth::user()-&gt;id);
          $members = Member::with('groups')-&gt;get();
          $selectedGroup = $groups-&gt;pluck('id')-&gt;toArray();
          return view('group.show',compact('groups','selectedGroup','members'));
      }
  </code></pre>
  
  <p>Now my code shows the groups alright but it doesn't fetch <strong>only</strong> 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</p>