I want update an array of ids.
Eloquent Query
$my_ids = json_encode($request->post('my_ids'));
Lead::whereIn('id', $my_ids)->update(['op' => 2]);
but I need to pass a string with comma.
How can I solve it?
CodePudding user response:
I believe the ids you receive from post request is object string so you need to decode that string in order to get an array.
$my_ids = json_decode($request->post('my_ids'), true);
Lead::whereIn('id', $my_ids)->update(['op' => 2]);