title: Eloquent relations - attach (but don't save) to Has Many
body: <p>I have the following relations set up:</p>
  
  <pre><code>class Page {
      public function comments() {
          return $this-&gt;hasMany('Comment');
      }
  }
  
  class Comment {
      public function page() {
          return $this-&gt;belongsTo('Page');
      }
  }
  </code></pre>
  
  <p>Pretty bog standard. One page can have many comments, and one comment belongs to a single page.</p>
  
  <p>I'd like to be able to create a new page:</p>
  
  <pre><code>$page = new Page;
  </code></pre>
  
  <p>and a comment</p>
  
  <pre><code>$comment = new Comment;
  </code></pre>
  
  <p>and attach the comment to the page, <strong>without saving any of it</strong></p>
  
  <pre><code>$page-&gt;comments-&gt;associate($comment);
  </code></pre>
  
  <p>I've tried the following:</p>
  
  <pre><code>// These are for one-to-many from the MANY side (eg. $comment-&gt;page-&gt;associate...)
  $page-&gt;comments-&gt;associate($comment);   // Call to undefined method Illuminate\Database\Eloquent\Collection::associate()
  $page-&gt;comments()-&gt;associate($comment); // Call to undefined method Illuminate\Database\Query\Builder::associate()
  
  // These 2 are for many-to-many relations, so don't work
  $page-&gt;comments-&gt;attach($comment);      // Call to undefined method Illuminate\Database\Eloquent\Collection::attach()
  $page-&gt;comments()-&gt;attach($comment);    // Call to undefined method Illuminate\Database\Query\Builder::attach()
  
  // These 2 will (if successful) save to the DB, which I don't want
  $page-&gt;comments-&gt;save($comment);        // Call to undefined method Illuminate\Database\Eloquent\Collection::save()
  $page-&gt;comments()-&gt;save($comment);      // Integrity constraint violation: 1048 Column 'page_id' cannot be null
  </code></pre>
  
  <p>The really odd thing is that doing the opposite (attaching the page to the comment) works correctly:</p>
  
  <pre><code>$comment-&gt;page()-&gt;associate($page);
  </code></pre>
  
  <p>The relevant docs are <a href="http://laravel.com/docs/eloquent#inserting-related-models">here</a> but they don't make any mention of attaching to the ONE side of a one-to-many. Is it even possible? (I feel like it should be)</p>