This commit is contained in:
Jitendra Singh 2020-01-21 12:58:11 +05:30
parent 176feecb55
commit 5cc7b4aae2
2 changed files with 14 additions and 1 deletions

View File

@ -122,7 +122,7 @@ class CategoryController extends Controller
{
$category = $this->categoryRepository->findOrFail($id);
$categories = $this->categoryRepository->getCategoryTree($id);
$categories = $this->categoryRepository->getCategoryTreeWithoutDescendant($id);
$attributes = $this->attributeRepository->findWhere(['is_filterable' => 1]);

View File

@ -76,6 +76,19 @@ class CategoryRepository extends Repository
: $this->model::orderBy('position', 'ASC')->get()->toTree();
}
/**
* Specify category tree
*
* @param integer $id
* @return mixed
*/
public function getCategoryTreeWithoutDescendant($id = null)
{
return $id
? $this->model::orderBy('position', 'ASC')->where('id', '!=', $id)->whereNotDescendantOf($id)->get()->toTree()
: $this->model::orderBy('position', 'ASC')->get()->toTree();
}
/**
* Get root categories
*