Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. // First - wipe the order's existing products
  2. $order->products()->sync([]);
  3. or
  4. $order->products()->delete();
  5.  
  6. // Now add some more products:
  7. $order->products()->attach(1, ['quantity' => 50]);
  8. $order->products()->attach(2, ['quantity' => 150]);
  9.  
  10. dd($order->products); // 0 items
  11. $order->load('products');
  12. dd($order->products); // 0 items
  13.  
  14.  
  15. DB Schema:
  16. table: order_product
  17. Fields: id, product_id, order_id, quantity
  18.  
  19. the 2 products ARE in the table.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement