Merge pull request #2081 from jitendra-webkul/1.0

Issue #2075 fixed
This commit is contained in:
Jitendra Singh 2020-01-21 12:58:57 +05:30 committed by GitHub
commit a8a28ccf60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

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

View File

@ -76,6 +76,19 @@ class CategoryRepository extends Repository
: $this->model::orderBy('position', 'ASC')->get()->toTree(); : $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 * Get root categories
* *