1

I have incoming data from android application but I cannot access them in my query

incoming data

[1ad3c212-6b4d-4dc3-8ae4-41aa6b12ff93, bd82e93d-8860-4cd3-8151-ef2c2e677b7a, a4d79d92-b02a-4ee9-ac1e-475745c4cc33]

usage

 $servicesPrice = Service::whereIn('service_id', $request->input('selectedServices'))->sum('price');

Error

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

Any idea?

3
  • it must be ["1ad3c212-6b4d-4dc3-8ae4-41aa6b12ff93","bd82e93d-8860-4cd3-8151-ef2c2e677b7a", "a4d79d92-b02a-4ee9-ac1e-475745c4cc33"] there is no number like this without "" it should be string you can validate from here jsonlint.com Commented Apr 8, 2021 at 5:40
  • @KamleshPaul how can I fix it? Commented Apr 8, 2021 at 5:40
  • tell android dev uuid is type of string to send string type inside array Commented Apr 8, 2021 at 5:41

1 Answer 1

1

there is a walk around here:

you can clear array braces and explode the string to array using ',' as separator:

$value=$request->input('selectedServices');
$value = str_replace(['[', ']'], null, $value);
$serviceIds= explode( ',',$value);
$servicesPrice = Service::whereIn('service_id', $serviceIds)->sum('price');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.