title: Laravel "undefined method Illuminate\Database\Query\Builder::attach()"
body: <p>I'm trying to associate related models during database seeding in Laravel 4. According to the documentation <a href="http://laravel.com/docs/eloquent#inserting-related-models" rel="noreferrer">here</a>, I can do it like this:</p>
  
  <pre><code>$user-&gt;roles()-&gt;attach(1);
  </code></pre>
  
  <p>So, in my database seed I'm running:</p>
  
  <pre><code>$package = Package::create([
      'name' =&gt; $faker-&gt;word,
      'summary' =&gt; $faker-&gt;sentence,
      'base_price' =&gt; $faker-&gt;randomFloat(2, 200, 10000)
  ]);
  
  // Attach 1-5 randomly selected items to this package
  foreach(range(1, 5) as $index)
  {
      $randomItem = Item::orderBy(DB::raw('RAND()'))-&gt;first();
      $package-&gt;items()-&gt;attach($randomItem-&gt;id);
  }
  </code></pre>
  
  <p>The packages items have already been seeded at this point, and they seed without problems. The above code gives this from Artisan though:</p>
  
  <pre><code>[BadMethodCallException]                                              
  Call to undefined method Illuminate\Database\Query\Builder::attach()
  </code></pre>
  
  <p>Someone <a href="http://irclogs.laravel.io/2013-05-04/15:39" rel="noreferrer">here</a> seems to think that the <code>attach()</code> method doesn't actually exist and the docs are wrong, but I find that hard to believe.</p>
  
  <p><strong>TL;DR What is the correct way to create many-to-many relationships in Eloquent?</strong></p>