I've vehicles
and vehicle_features
. Those are combined via a many-to-many relationship. Let's say I have an array of IDs from vehicle_features. Now I want all vehicles which have all of the given features.
I've tried a combination of whereHas
and whereIn
, but it returns all vehicles with one match:
public function scopeTopFeatures(Builder $query, $topFeatureIds): Builder
{
return $query->whereHas('features', function (Builder $query) use ($topFeatureIds) {
$query->whereIn('vehicle_feature_id', $topFeatureIds);
});
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3mCTXkG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire