I have three models:
Product
Inventory
Order
The relationship between them like:
Order has manyToMany relationship with Inventory and $nventory->belongsTo('product');
/** Product Model **/
class Product extend Model
{
public function inventories()
{
return $this->hasMany('App\Inventory');
}
}
/** Inventory Model **/
class Inventory extend Model
{
public function products()
{
return $this->belongsTo('App\Product');
}
}
/** Order Model **/
class Order extend Model {
public function inventories()
{
return $this->belongsToMany('App\Inventory','order_items');
}
//how do I get this?
public function products()
{
}
}
The hasManyThrough will not work because of the order_items pivot table. How can I get the products of a order?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kMimGd
via IFTTT
Aucun commentaire:
Enregistrer un commentaire