mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
getSubCatById added
This commit is contained in:
parent
b0b858b7ea
commit
b67ae3e9d2
@ -24,6 +24,19 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
|||||||
->orderBy('sort_order')
|
->orderBy('sort_order')
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
public function getSubCatById($id)
|
||||||
|
{
|
||||||
|
$cats = $this->model->newQuery()
|
||||||
|
->where('parent_category_id', $id)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($cats as $cat) {
|
||||||
|
$subCount = $this->model->newQuery()->where('parent_category_id', $cat->id)->count();
|
||||||
|
$cat->hasChild = !!$subCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cats;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCategoriesLevel2()
|
public function getCategoriesLevel2()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,6 +10,8 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface
|
|||||||
|
|
||||||
public function getCategoryById($id);
|
public function getCategoryById($id);
|
||||||
|
|
||||||
|
public function getSubCatById($id);
|
||||||
|
|
||||||
public function findBySlug($slug);
|
public function findBySlug($slug);
|
||||||
|
|
||||||
public function getParentCategoryById($id);
|
public function getParentCategoryById($id);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user