diff --git a/application/blocks/categoryBlock.php b/application/blocks/categoryBlock.php index 5b88e91..9e418c1 100644 --- a/application/blocks/categoryBlock.php +++ b/application/blocks/categoryBlock.php @@ -19,7 +19,7 @@ public static function view($CI, array $vars) [ 'categories_arr' => $CI->category_model->get_all_category_ids_recursive(), 'parent' => $CI->category_model->get_category_parents($vars['category_id']), - 'children' => $CI->category_model->get_category_children($vars['category_id']), + 'children' => $CI->category_model->get_all_category_ids_recursive($vars['category_id']), 'current' => $vars['category_id'] ], TRUE diff --git a/application/models/Category_model.php b/application/models/Category_model.php index 4bce58f..018e7bd 100755 --- a/application/models/Category_model.php +++ b/application/models/Category_model.php @@ -24,28 +24,6 @@ public function get_all_category_ids_recursive(int $parent_id = 0): array return $ids; } - /** - * Get all children categories of $id - * - * @param int $id Category Id - * @return array - */ - public function get_category_children(int $id): array - { - $this->db->select('*'); - $this->db->from('categories'); - $this->db->where('parent_category_id', $id); - $query = $this->db->get(); - $ids = []; - foreach ($query->result_array() as $row) - { - $temp = $this->get_category_children($row['category_id']); - $ids[$row['category_id']] = $temp; - } - - return $ids; - } - /** * Gets all parent categories of $id *