I am creating an application where a building has facilities and I want to make a query to get a building where its facility can be, for example; ["stand-by-generator", "wifi", "swimming-pool"].
The code below returns buildings where facilities are one of these ["stand-by-generator", "wifi", "swimming-pool"] instead of all of these.
This is my query builder. I am actually using a query filter.
public function apply(Builder $builder, $value): Builder
{
// $value = ["stand-by-generator", "wifi", "swimming-pool"];
return $builder->whereHas('facilities', function ($query) use ($value) {
$query->whereIn('slug', $value);
});
}