title: Laravel many-to-many relationship on the same model
body: <p>I have a model <code>Job</code>.</p>
  
  <p>A <code>Job</code> can require other <code>Jobs</code> be completed before it can begin.</p>
  
  <p>A <code>Job</code> may be the pre-required job for many <code>Jobs</code> at once.</p>
  
  <p>So, say <code>Job A</code> depends on <code>Job B</code> and <code>Job C</code>, I would like to be able to call <code>job-&gt;requiredJobs</code> and get those two jobs.</p>
  
  <p>As it stands, I have the following:</p>
  
  <pre><code>class Job extends Model
  {
  
      public function requiredJobs() 
      {
          return $this-&gt;hasMany('App\Job', 'required_job_id');
      }
  }
  </code></pre>
  
  <p>However, I'm finding that if I create a <code>Job D</code> and have it require <code>Job B</code> and <code>Job C</code>, it overrides <code>Job A</code>'s required jobs field, since it seems to be adding <code>required_job_id</code> onto the required jobs, instead of creating an array on the dependent job.</p>
  
  <p>Hope this all makes sense! I'm not entirely sure if I need two definitions, or if <code>hasMany</code> is the wrong relationship (<code>belongsToMany</code> instead?...)</p>