filter options

This commit is contained in:
merdan 2022-11-02 13:53:40 +05:00
parent 785cc33f31
commit 6c50b24554
2 changed files with 3 additions and 5 deletions

View File

@ -63,7 +63,7 @@ class Brands extends \Webkul\RestApi\Http\Controllers\V1\Shop\ResourceController
$query = $query->orderBy('position', 'desc')->orderBy('name', 'asc');
}
return $query;
return $query->has('products');
});
if (is_null($request->input('pagination')) || $request->input('pagination')) {

View File

@ -33,16 +33,14 @@ class Categories extends CategoryController
public function filters($id){
$category = $this->getRepositoryInstance()->with(['filterableAttributes','brands' => function ($q){
$q->take(20)->orderBy('position', 'desc')->orderBy('name', 'asc');
$q->has('products')->take(20)->orderBy('position', 'desc')->orderBy('name', 'asc');
} ])
->find($id);
$brendler = $category->brands()->has('products')->get();
if($category)
return response([
'attributes' => Attribute::collection($category->filterableAttributes),
'brands' => Brand::collection($brendler),
'brands' => Brand::collection($category->brands),
]);
else{
return response(['error'=>'not found'],404);