Laravel Get Collection From Array of IDs -
i have array of user ids i'm trying collection of. have been using following foreach loop, realize each loop makes, overrides previous data.
$users = db::table('user_tags')->where('tag_name', $tag)->wherenotnull('user_id')->lists('user_id'); $users = array_unique($users);  foreach ($users $key => $value) {     $users = user::where('id', $value)->get();   }   how can return collection users in original array?
thanks!
there's easier way..
$ids = db::table('user_tags')->where('tag_name', $tag)->wherenotnull('user_id')->lists('user_id'); $users = user::wherein('id', $ids)->get();      
Comments
Post a Comment