getMains is used by store

This commit is contained in:
Fatih Alp 2021-03-27 22:35:19 +03:00
parent ab92313c4c
commit 3c91e8eef9
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -9,4 +9,6 @@ interface CategoryInterface extends EntryInterface
public function getMetaDescription();
public function getParent();
public function getMains($id);
}