laravel - Using in_array within elequent call -
i can make following call
$usergroups = auth::user()->getgroups();
the above output following
array:10 [▼ 0 => "admin" 1 => "teama" 3 => "usa" 4 => "security" 9 => "users" ]
so can see member of of above groups. have clients table, , 1 of fields of table team. example client so
#attributes: array:11 [▼ "id" => "3" "clientname" => "some client" "contactemail" => "" "team" => "teama" "created_at" => "2016-07-04 15:08:15" "updated_at" => "2016-07-04 15:08:15" ]
what trying clients have team part of logged in users groups. can see apart of teama therefor want clients have team value of teama. thinking along lines of this
$clients = client::where('team', in_array('teama', $usergroups))->get();
the above returns empty result set, demonstrates after.
how can achieve this?
thanks
it sounds if looking wherein?:
$clients = client::wherein('team', $usergroups)->get();
Comments
Post a Comment