Calling child relations from model in laravel

I want to fetch the categories with products and images. I have following relation: Product Model

class Product extends Model {       public function productCategory() {          return $this->belongsToMany('ProductCategory');     }      public function addtionalImages() {          return $this->hasMany('ProductImage');     } } 

Product Category Model

class ProductCategory extends Model {      public function product() {         return $this->hasMany('Bazar\Models\Product', 'product_catid')                 ->orderBy('id', 'DESC')->limit(10);     }   } 

This is how i am using eager loading:

$categories = ProductCategory::select('product_categories.*')               ->with(['product'])->Paginate(20); 

This returns the category and products not the additionalImage, images are related to products not with the categories, I tried ->with(['product', 'addtionalImages']) but no success, can anyone let me know what i missed? or how do i achieve?


Category: eloquent Time: 2016-07-30 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.140 (s). 12 q(s)