atrr option cat
This commit is contained in:
parent
9c40282ea1
commit
b9d8e24d66
|
|
@ -58,10 +58,13 @@ class FilterOptions extends \Webkul\RestApi\Http\Controllers\V1\Shop\ResourceCon
|
|||
}
|
||||
|
||||
if($category = $request->input('category')){
|
||||
$query->join('product_attribute_values','product_attribute_values.integer_value','=','attribute_options.id')
|
||||
->join('product_categories','product_categories.product_id','=','product_attribute_values.product_id')
|
||||
->where('product_attribute_values.attribute_id','attribute_options.attribute_id')
|
||||
->where('product_categories.category_id',$category);
|
||||
$query->join('product_attribute_values',function ($q) use ($request){
|
||||
$q->on('product_attribute_values.integer_value','=','attribute_options.id')
|
||||
->where('product_attribute_values.attribute_id',$request->get('attribute_id'));
|
||||
})->join('product_categories',function ($q) use($category){
|
||||
$q->on('product_categories.product_id','=','product_attribute_values.product_id')
|
||||
->where('product_categories.category_id',$category);
|
||||
});
|
||||
}
|
||||
return $query->where('attribute_id',$request->get('attribute_id'));
|
||||
});
|
||||
|
|
@ -74,8 +77,4 @@ class FilterOptions extends \Webkul\RestApi\Http\Controllers\V1\Shop\ResourceCon
|
|||
|
||||
return $this->getResourceCollection($results);
|
||||
}
|
||||
|
||||
public function index($attribute_id){
|
||||
return $this->getRepositoryInstance()->findWhere(['attribute_id'=>$attribute_id]);
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,6 @@ Route::group(['prefix' => 'api'], function () {
|
|||
Route::get('descendant-categories', [Categories::class, 'descendantCategories'])->name('api.descendant-categories');
|
||||
Route::get('categories', [Categories::class, 'allResources'])->name('api.categories');
|
||||
Route::get('categories/{id}/filters',[Categories::class,'filters']);
|
||||
Route::get('filter-options/{attribute_id}', [FilterOptions::class, 'index']);
|
||||
Route::get('attribute-options', [FilterOptions::class, 'allResources']);
|
||||
Route::get('brands', [Brands::class, 'allResources']);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue