mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
getMains is used by store
This commit is contained in:
parent
ab92313c4c
commit
3c91e8eef9
@ -20,4 +20,26 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
{
|
||||
return $this->parent_category;
|
||||
}
|
||||
public function getMains($id)
|
||||
{
|
||||
$categories = array();
|
||||
$z = 1;
|
||||
for ($i = 1; $i <= $z; $i++) {
|
||||
if ($main = $this->newQuery()->where('id', $id)->first()) {
|
||||
$new = array();
|
||||
$new['id'] = $main->id;
|
||||
$new['val'] = $main->name;
|
||||
$new['slug'] = $main->slug;
|
||||
$categories[] = $new;
|
||||
if ($main->parent_category_id != null) {
|
||||
$id = $main->parent_category_id;
|
||||
$z++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$categories = array_reverse($categories);
|
||||
unset($categories[count($categories) - 1]);
|
||||
return $categories;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,4 +9,6 @@ interface CategoryInterface extends EntryInterface
|
||||
public function getMetaDescription();
|
||||
|
||||
public function getParent();
|
||||
|
||||
public function getMains($id);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user