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

java - unable show chart in xls document using jasper reports -

javascript - How to change image src on success AJAX -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -