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