• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Laravel Many to Many, how to insert/get data inside the pivot table?

Resolved: Laravel Many to Many, how to insert/get data inside the pivot table?

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

in laravel 9 I implement many to many relationship.
I have three table, shop , product and product_shop table.
each shop can have number of every single product. and each product can exist in multiple shops.
the question is how can I insert/get the number of product inside the product_shop table?
what relationship syntax I have to use?
product_shop table :
thanks

Answer:

You can use pivot. For example,
And if you want to insert,

If you have better answer, please add a comment about this, thank you!

eloquent laravel many-to-many php relationship
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why when i change manualy the url on my react page it ignores the .css file?

24/03/2023

Resolved: navigate and redirect not redirecting to path in react router

24/03/2023

Resolved: Time Complexity: Find the number of people who know a secret leetcode 2327

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.