mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#1893 [dress-theme] GG Anasayfa Giydirme
This commit is contained in:
parent
6c27bc0d2b
commit
4ec10c4faa
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user