我有你的桌子:Orders
,,,Products
。Products_images
我需要得到所有订单,为此我这样做:
$orders = Order::with("products")->where("user_id", Auth::guard('api')->user()->id)->orderBy('id')->get();
with("products")
模型中的函数在哪里Order
public function products()
{
return $this->hasOne("App\Product", "id", "product_id");
}
所以,我已经连接了两个表。我还需要在这个查询Products
中用表连接表。Products_images
我怎样才能做到这一点?