getSubCatById added

This commit is contained in:
Fatih Alp 2021-03-13 19:45:32 +03:00
parent b0b858b7ea
commit b67ae3e9d2
2 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,19 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
->orderBy('sort_order')
->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()
{

View File

@ -10,6 +10,8 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface
public function getCategoryById($id);
public function getSubCatById($id);
public function findBySlug($slug);
public function getParentCategoryById($id);