I have 3 tables, Order, Products, Order_Products. I need get all field from order and products, thats ok using hasManyThrough(). But i need 1 more field from Order_products. How can i get this field ?
public function products()
{
//in order model
return $this->hasManyThrough('App\Models\Product','App\Models\OrderProduct','order_id','id','id','product_id');
}
using sql i need query like
SELECT
products
.*, order_products
.order_id
, order_products
.count
as order_count
FROM
products
INNER JOIN order_products
ON order_products
.product_id
= products
.id
WHERE
order_products
.order_id
= 2