Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument 1 passed to Illuminate\\Database\\Query\\Builder::cleanBindings() must be of the type array, string given

I update 2 data, the first data is in the normal table, the second data uses EAV, therefore I have to use where to update the data that has the input ID

What im doing wrong..im getting this error..

this my controller

this is normal table

$vendor = Vendor::find($request->id);
$vendor->is_active = '0';
$vendor->name = $request->name;
$vendor->address = $request->address;
$vendor->save();

this is EAV Table

$values = [
    'detail'  => $request->detail,
    'join_at' => Carbon::now(),
];
VendorDetail::whereIn('vendor_id', $request->id)->update($values);
like image 390
misry Avatar asked Nov 30 '19 09:11

misry


2 Answers

When using whereIn() in second argument you must be pass array

VendorDetail::whereIn('vendor_id', [$request->id])->update($values);

But in your case you can use

VendorDetail::where('vendor_id',$request->id)->update($values);
like image 151
Davit Zeynalyan Avatar answered Oct 01 '22 11:10

Davit Zeynalyan


I got the same error in select query while using Eloquent. So posting my solution also. As already mentioned in other answers,

When using whereIn() in the second argument you must be array

My error was that I was using "=" as the second parameter and actual array as 3rd parameter. Removing the equal sign parameter like below resolved my issue.

$innerQuery->whereIn('wo.wm_is_completed', $completedFlagArr);
like image 25
SMJ Avatar answered Oct 01 '22 13:10

SMJ