You can write the table name as alias of the field
$attrquery->whereIn('mytable.value', $this->select_filter_attr);
Hello, I am preparing an e-commerce site. I have two tables linked by Releationship. The first table is Products and the second is ProductAttributes. It is linked by product_id in two tables. When I query my Products table, in my Product model file
public function attributes()
{
return $this->hasMany(ProductAttribute::class, 'product_id');
}
I want to extract only eligible products using relation. The query is like this:
$query->where('slug->tr', $this->slug);
})
->whereHas('attributes' , function($attrquery){
$attrquery->whereIn('value', $this->select_filter_attr);
})->paginate(100);
But the problem is, when I do whereIN('value' , ['2021','LOW']) using the value field in the ProductAttributes table, it pulls all the products with both 2021 and LOW values, while I want it to pull the products with both 2021 and LOW fields at the same time. How do I do this, thanks in advance.
Please or to participate in this conversation.