How can I update pivot table on laravel?

后端 未结 1 1041
广开言路
广开言路 2020-12-22 07:03

I use laravel 5.3

I have 3 table : table product, table category and table products_categories

table product : id, name, etc

table category : id, nam

1条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 07:58

    Try to use the sync() function

    Product::find($product_id)->categories()->sync($array_of_categories_id)
    

    0 讨论(0)
提交回复
热议问题