Ich habe die Tabellen: Orders
, Products
, Products_images
.Wie verbinde ich drei Tische in Laravel?
Ich brauche ll Aufträge zu bekommen, denn das tue ich:
$orders = Order::with("products")->where("user_id", Auth::guard('api')->user()->id)->orderBy('id')->get();
Wo with("products")
ist Funktion in Modell Order
public function products()
{
return $this->hasOne("App\Product", "id", "product_id");
}
Also, ich habe zwei Tabelle verbunden. Auch ich brauche Verbindung mit Tabelle Products
mit Tabelle Products_images
in dieser Abfrage.
Wie kann ich das tun?