Here the situation.
I have a user table, a role table (different users can have the same role) and a post table (different users can be linked to a same post - multi authors post). I also have two join tables that link user and role and user and post. I have built all relationships (many-to-many).
But now I try to get all users that have a particular role ('id' = 2 for example) and have contributed to a particular post ('id' = 45 for example).
I can do it with one criteria :
$roles = App\Role::where('id', 2)->first();
foreach ($roles->users as $user) {
}
But I didn't find the solution with two criterias (role id and post id).