public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $postId) { if (!($post = \Zingabory\Gallery\Models\Category::find($postId))) { continue; } $post->delete(); } Flash::success('Supprimé avec succès'); } return $this->listRefresh(); }
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; }
protected function loadCategory() { if (!($categoryId = $this->property('categoryFilter'))) { return null; } if (!($category = CategoryModel::whereSlug($categoryId)->first())) { return null; } return $category; }