I'm geting the following error if I try to get database entrys where the name contains a passed string.
Invalid argument supplied for foreach()
.
$search = $request['search'];
$key_search = explode(' ', $search);
$usergroups = Usergroups::whereIn('name', 'like', '%' . $search . '%')->paginate(3);
$key_search looks something like this: [0 => "Test", 1 => "Unicorn"];
Now I want to get every entry where the name column has data that contains the passed strings and get the query results with paginate();
I've also tried something like a foreach loop that pushes the entrys into another array but this haven't worked for me as well cause the entrys are Objects and not arrays. Thats why array_push coulnd't handle this.
Does someone know what I can do to get the entrys?
Thanks for your help and sorry for my bad english!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire