I’m currently working on a project on laravel 8.
I have 3 tables : 1.customers 2.books 3.loans
I want to be able to make a request like
$data=DB::table('emprunts')->where('customerid',$id->number)->first(); but where it would count the instances of loans with this customerid and return it into a variable.
I tried with
$limitemprunts = Emprunt::WhereIn('clientid',$search_text)->where('clientid',$search_text)->distinct()->get()->count();
but it gives me this error :
TypeError Argument 1 passed to
IlluminateDatabaseQueryBuilder::cleanBindings() must be of the type
array, string given, called in
on line 919
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
You will need to convert the second parameter of
whereIn into an array:
$limitemprunts = Emprunt::WhereIn('clientid',[$search_text])->distinct()->get()->count();
As said in the comment, the answer was really simple : feed it an array