php - How to eagerly load multiple related models in Laravel 5? -


i have relationships follows:

an order has many products, , product has many orders.

class order extends model {     ...     public function products()     {         return $this->belongstomany('app\product');     } } 

a product has many images, , image belongs product.

class product extends model {     ...     public function images()     {         return $this->hasmany('app\image');     } } 

for order $order, can load products $order->load('products'), how eagerly load images of products $order?

there 2 ways achieve this, can $order->load('products.images') or add property $with = ['images'] product model/entity.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -