there is a three table
user,memember,group_member(relation mem_id,group_id) many to many
i have define a relation for group on member model
public function group(){
return $this->belongsToMany('Model\Group', 'group_member', 'mem_id', 'group_id');
}
using above relation i can retrieve a member asigned group using
Model\Member::with('group')->find('member_id')
now i want those group where member is not assigned . i have done 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();
there is a another option rather then subquery ??
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2dmNlG3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire