Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

You need where in and having count(distinct .. ) mix in SQL (MySQL). You can also do it with has in some cases. Show the relation and the tables.

Last updated 1 year ago.
0

Well, this is the solution (thx to jarektkaczyk)

$countries = [1,5,9];

User::whereHas('countries', function ($q) use ($countries) {
  $q->whereIn('users_countries.country_id', $countries);
}, '=', count($countries) )->get();

I asked the same in stackoverflow if anyone is interested: http://stackoverflow.com/questions/24961783/laravel-get-an-use...

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Luddinus luddinus Joined 18 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.