vendredi 11 mars 2016

Laravel DB Query WHERE value matches at least one value from array

Using Laravel 5.0. I am trying to build a DB Query in Laravel. Here's what I have so far:

$input = Input::get('option'); //option=tag1,tag2,tag3
$check_tags= explode(',', $input);
$chosen_users = DB::table('users')->whereIn('user_tags', $check_tags)->get();

I'm trying to display a result of users where the value of the 'user_tags' column has at least one of the tags in the input. Eg display user 1 which has "tag4,tag1" if input is "tag1,tag2,tag3".



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire