public function get_categories_by_parents_id_in($ids_array) { $category = Category::whereIn('parent_id', $ids_array)->get(); if (count($category) > 0) { return $category->toArray(); } else { return ""; } }
public function syncCategories(array $categories) { Category::addNeededCategories($categories); if (count($categories)) { $this->categories()->sync(Category::whereIn('name', $categories)->where('user_id', $this->user_id)->lists('id')->all()); return; } $this->categories()->detach(); }
public static function getCategories() { $posts = Post::where('lang', '=', Lang::getLocale())->where('published', '=', 1)->lists('id'); $categories = Category::whereIn('post_id', $posts)->lists('name'); return array_count_values($categories); }
private function dopublish(Request $request, $value) { $category = Category::whereIn('id', $request->ids)->update(array('is_published' => $value)); $response = ['model_type' => 'Category', 'ids' => $request->ids, 'action_type' => $value == 1 ? "Publish" : "Unpublish"]; return json_encode($response); }