Ejemplo n.º 1
0
 protected function loadCategories()
 {
     $categories = ProductCategory::orderBy('name');
     if (!$this->property('displayEmpty')) {
         $categories->whereExists(function ($query) {
             $query->select(Db::raw(1))->from('abnmt_products_products_categories')->join('abnmt_products_products', 'abnmt_products_products.id', '=', 'abnmt_products_products_categories.product_id')->whereNotNull('abnmt_products_products.published')->where('abnmt_products_products.published', '=', 1)->whereRaw('abnmt_products_categories.id = abnmt_products_products_categories.category_id');
         });
     }
     $categories = $categories->get();
     /*
      * Add a "url" helper attribute for linking to each category
      */
     $categories->each(function ($category) {
         $category->setUrl($this->categoryPage, $this->controller);
     });
     return $categories;
 }