Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // First - wipe the order's existing products
- $order->products()->sync([]);
- or
- $order->products()->delete();
- // Now add some more products:
- $order->products()->attach(1, ['quantity' => 50]);
- $order->products()->attach(2, ['quantity' => 150]);
- dd($order->products); // 0 items
- $order->load('products');
- dd($order->products); // 0 items
- DB Schema:
- table: order_product
- Fields: id, product_id, order_id, quantity
- the 2 products ARE in the table.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement