Join columns with HasMany in Laravel

  Kiến thức lập trình

I have 3 tables – users, products and user_products. I try get user_products for user with products data. I can get user_products by $this->hasMany(ProductUser::class) but how can I get products atributes (title and other) from Product table in one query? Or I have to do query for every product? I’m new in Laravel, tnx.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT