- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
foreach($mainCategories as $category){
$subcategory = AdCategory::where('parent_id', $category->id)->get();
if(!$subcategory->isEmpty()){
foreach($subcategory as $item){
$subcategoryArray[] = $item->id;
}
$category->adsCount = Ad::whereIn('category_id', $subcategoryArray)->onlyRegion($currentRegion->id)->active()->count();
$subcategoryArray = [];
}else{
$category->adsCount = Ad::where('category_id', $category->id)->onlyRegion($currentRegion->id)->active()->count();
}
}
Комментарии (0) RSS
Добавить комментарий