mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-12 16:26:07 -06:00
fixed category calculate
This commit is contained in:
parent
61a7bbcad6
commit
994c32fdeb
@ -24,6 +24,7 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getSubCatById($id)
|
||||
{
|
||||
$cats = $this->model->newQuery()
|
||||
@ -108,7 +109,8 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
||||
|
||||
public function getLevelById($id)
|
||||
{
|
||||
return count($this->getParentCategoryById($id));
|
||||
$parents = $this->getParentCategoryById($id);
|
||||
return (is_array($parents)) ? count($parents) : null;
|
||||
}
|
||||
|
||||
public function getCategoriesByName($keyword)
|
||||
|
||||
@ -44,6 +44,8 @@ class CalculateCategoryLevel
|
||||
|
||||
$level = $categoryRepository->getLevelById($category_id);
|
||||
|
||||
if($level)
|
||||
{
|
||||
DB::table('cats_category')->where('id', $category_id)
|
||||
->update(array(
|
||||
'level' => $level,
|
||||
@ -51,3 +53,4 @@ class CalculateCategoryLevel
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user