Relationship m2m, Eloquent

Posted 5 days 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.

Reply to

Use Markdown with GitHub-flavored code blocks.