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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -