ı have have 3 tables in my projects they are -Products(can have Multiple Variants ) -Variants (belongsto product) -product_attributes (this have product_id,attribute_id,value_id)
ı want to filter variants from a product by value ids thats comes from form request as example (1,2,6) ı have tried like this :
$poruduct_id=$request->product_id; $value_ids=$request->value_ids
$searched_variants=Variant::whereHas( 'product.attributeValues' , function ($query) use($value_ids,$product_id){ $query->whereIn('value_id',[$value_ids]); })->where('product_id',$product_id)->get();
dd($searched_variants);
but the problem is the query returns all records from the product .. what is the solition to filter exacly the values that the product Variants have ? thank u
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire