Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Fix #41 Remove exact same method Category_model::get_category_children() #50

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/blocks/categoryBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions application/models/Category_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down