title: Laravel: How to make a relationship between two table that has a reference table
body: <p>I have 3 tables.</p>
  
  <p><strong>People, Assignments and Projects</strong></p>
  
  <blockquote>
    <p>each person in People table can be assigned to one or more Projects.
    Each project in Projects table can have one ore more person assigned to it.</p>
  </blockquote>
  
  <p>Here are the columns of each table:</p>
  
  <p>People</p>
  
  <ul>
  <li>id</li>
  <li>name</li>
  </ul>
  
  <p>Assignments:</p>
  
  <ul>
  <li>person_id </li>
  <li>project_id</li>
  </ul>
  
  <p>Projects</p>
  
  <ul>
  <li>id</li>
  <li>title</li>
  </ul>
  
  <p>My question is: in my Project model, how do I define the relationship?</p>
  
  <p>What I want is to be able to get the names of all person assigned to a specific project.</p>
  
  <p>I NEED:</p>
  
  <pre><code>$project-&gt;assignedPeople
  </code></pre>
  
  <p>So I can:</p>
  
  <pre><code>foreach($projects as $project)
  $project-&gt;title
    foreach(projects-&gt;assignedPeople as $person)
    $person-&gt;name
  </code></pre>
  
  <p>I NEED YOUR HELP PLEASE
  THANK YOU!</p>