Ejemplo n.º 1
0
 /**
  * Get all the images associated with a product
  * incl.
  * featured image, related images, etc
  *
  * @param unknown $cast
  * @return array
  */
 public function images()
 {
     $featured_image = array();
     if (!empty($this->featured_image['slug'])) {
         $featured_image = array($this->featured_image['slug']);
     }
     $related_images = \Dsc\ArrayHelper::where($this->images, function ($key, $ri) {
         if (!empty($ri['image'])) {
             return $ri['image'];
         }
     });
     $images = array_unique(array_merge(array(), (array) $featured_image, (array) $related_images));
     return $images;
 }
Ejemplo n.º 2
0
 /**
  * Get all the images associated with a product
  * incl. featured image, related images, and variant images
  *  
  * @param unknown $cast
  * @return array
  */
 public function images()
 {
     $featured_image = array();
     if (!empty($this->featured_image['slug'])) {
         $featured_image = array($this->featured_image['slug']);
     }
     $variant_images = \Dsc\ArrayHelper::where($this->variantsInStock(), function ($key, $variant) {
         if (!empty($variant['enabled']) && !empty($variant['quantity']) && !empty($variant['image'])) {
             return $variant['image'];
         }
     });
     $related_images = \Dsc\ArrayHelper::where($this->images, function ($key, $ri) {
         if (!empty($ri['image'])) {
             return $ri['image'];
         }
     });
     $images = array_unique(array_merge(array(), (array) $featured_image, (array) $variant_images, (array) $related_images));
     return $images;
 }