php - How to make a relationship between 3 models

I have 3 model named User, Product and Review. I used one to many relationship between User and Product, on the other hand I use one to many between Product and Review. I can find related product from user model and find related reviews from product model.

How can I find related product reviews from user model?

Answer

Solution:

You should use has-many-through relationship.

https://laravel.com/docs/9.x/eloquent-relationships#has-many-through

The "has-many-through" relationship provides a convenient way to access distant relations via an intermediate relation.

Source