I have the usual users, groups and group\_user tables. I know the raw SQL that I want:

```
SELECT group_user.group_id, users.* FROM users
INNER JOIN group_user ON users.id = group_user.user_id
WHERE group_user.group_id IN
(SELECT group_id FROM group_user WHERE user_id=?)
ORDER BY group_user.group_id;

```

where ? is replaced current user's id.

but, I want to use Eloquent (outside of laravel) for this. I have tried using a User model with a groups method 

```
public function groups() {
    return $this->belongsToMany('\Smawt\User\Group');
}

```

and a Membership model with a users method 

```
public function users($group_id) {
    return $this->where('group_id', '=', $group_id)->get();
}

```

and then I loop through the groups and then loop through all its members. Finally, I append all the data to get one $users object at the end, to pass through to my view.

```
$thisMembership = new Membership;
$myGroups = $app->auth->groups;

$users = [];

foreach ($myGroups as $myGroup) {

    foreach ($thisMembership->users($myGroup->id) as $myUser) {

        $thisUser = $app->user->where('id', '=', $myUser->user_id)->first();
        $thisUser->group_id = $myGroup->id;

        array_push($users, $thisUser);
    }
}

```

Then in my view I loop through my $users as normal. Although this method works, it will not be very efficient as I am unable to work out how to use Eager Loading with it.

Is there a simpler more 'Eloquent' way of getting an object of users who are in the same group as the current user? I don't want just want a list, or an array, as I want to use the other methods defined in my user model.