There are three tables:
user,member,group_member(relation mem_id,group_id) many to many
I have defined a relation for a group on member model
public function group(){
return $this->belongsToMany('Model\Group', 'group_member', 'mem_id', 'group_id');
}
using the above relation I can retrieve a member assigned to a group using
Model\Member::with('group')->find('member_id')
now I want those groups where the member is not assigned.
I am able to do this using
$arg['ids'] = $member->group->lists('_id');
$group = Group::where('user_id',$user_id)->whereNotIn('_id',$arg['ids'])->limit($arg['limit'])->offset($arg['offset'])->get();
Is there another option rather than using a subquery?