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);
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire