#1893 [dress-theme] GG Anasayfa Giydirme

This commit is contained in:
Diatrex 2020-08-11 17:15:31 +03:00
parent 6c27bc0d2b
commit 4ec10c4faa
2 changed files with 35 additions and 1 deletions

View File

@ -1,8 +1,35 @@
<?php namespace Visiosoft\CatsModule\Category;
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
{
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)
{
return $this->model->newQuery()
$cats = $this->model->newQuery()
->where('parent_category_id', $id)
->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)