Relationship m2m, Eloquent. HELP PLS

Posted 2 months ago by vovkacrackhead

I have 3 tables: orders, products, order_product. There are 4 columns in order_product table: id, order_id, product_id, count. I already make a relationship between tables. How can i create new order and immediately attach him few products with count from form? I created new func in ordercontroller:

public function newOrder(){ $order = new Order([ /data of order/ ]);

$order->save();

...

} what should i do next ?

Please sign in or create an account to participate in this conversation.