Exemplo n.º 1
0
 protected function loadCategories()
 {
     $categories = CategoryModel::orderBy('name');
     if (!$this->property('displayEmpty')) {
         /* $categories->whereExists(function($query) {
                $query->select(Db::raw(1))
                    ->from('rainlab_blog_posts_categories')
                    ->join('rainlab_blog_posts', 'rainlab_blog_posts.id', '=', 'rainlab_blog_posts_categories.post_id')
                    ->whereNotNull('rainlab_blog_posts.published')
                    ->where('rainlab_blog_posts.published', '=', 1)
                    ->whereRaw('rainlab_blog_categories.id = rainlab_blog_posts_categories.category_id');
            });*/
         $categories->whereGalleryCountNotNull();
     }
     $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;
 }