title: Laravel: Associate models without saving in a HasMany relationship
body: <p>I have a model like so:</p>
  <pre><code>class Bill extends Model {
      public function billItems(): HasMany
      {
          return $this-&gt;hasMany(BillItem::class);
      }
  }
  </code></pre>
  <p>I want to be able to create a new bill and associate it with bill items without saving any of them, so that I can save them later if it passes some condition (e.g. if the payment went through).</p>
  <p>e.g.</p>
  <pre><code>$bill = new Bill();
  
  $billItem1 = new BillItem();
  $billItem1-&gt;name = &quot;T-Shirt&quot;;
  $billItem1-&gt;price = 250;
  
  $billItem2 = new BillItem();
  $billItem2-&gt;name = &quot;Cap&quot;;
  $billItem2-&gt;price = 174;
  
  // $bill-&gt;billItems()-&gt;attachWithoutSaving([$billItem1, $billItem2]); // Bit I need help with
  // ... 
  
  $paymentIsSuccessful = true; // actual code would be some payment logic
  if ($paymentIsSuccessful) {
     $bill-&gt;save();
     foreach($bill-&gt;billItems as $billItem) {
        $billItem-&gt;save();
     }
  }
  </code></pre>
  <p>How can I do this?</p>