Merge pull request #630 from openclassify/dia

#1893 [dress-theme] GG Anasayfa Giydirme
This commit is contained in:
Ozcan Durak 2020-08-11 19:34:32 +03:00 committed by GitHub
commit b2b17e1975
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View File

@ -1,8 +1,35 @@
<?php namespace Visiosoft\CatsModule\Category; <?php namespace Visiosoft\CatsModule\Category;
use Anomaly\Streams\Platform\Entry\EntryCriteria; use Anomaly\Streams\Platform\Entry\EntryCriteria;
use Anomaly\Streams\Platform\Stream\Contract\StreamInterface;
use Illuminate\Database\Eloquent\Builder;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
class CategoryCriteria extends EntryCriteria class CategoryCriteria extends EntryCriteria
{ {
private $categoryRepository;
public function __construct(
Builder $query, StreamInterface $stream, $method,
CategoryRepositoryInterface $categoryRepository
)
{
parent::__construct($query, $stream, $method);
$this->categoryRepository = $categoryRepository;
}
public function getMainCats() {
$mainCats = $this->categoryRepository->newQuery()
->whereNull('parent_category_id')
->orderBy('sort_order')
->get();
foreach ($mainCats as $cat) {
$subCount = $this->categoryRepository->newQuery()->where('parent_category_id', $cat->id)->count();
$cat->hasChild = !!$subCount;
}
return $mainCats;
}
} }

View File

@ -50,9 +50,16 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
public function getSubCatById($id) public function getSubCatById($id)
{ {
return $this->model->newQuery() $cats = $this->model->newQuery()
->where('parent_category_id', $id) ->where('parent_category_id', $id)
->get(); ->get();
foreach ($cats as $cat) {
$subCount = $this->model->newQuery()->where('parent_category_id', $cat->id)->count();
$cat->hasChild = !!$subCount;
}
return $cats;
} }
public function getSingleCat($id) public function getSingleCat($id)