1

I have used multi-select in laravel search. I want to search for data on multiple values. Here is my code

getting an array from the request

$req->state

Getting all the data from request

[
'DELHI','MAHARASHTRA','KARNATAKA',
]
$data = tbl_company::query()
                ->where(
                    "state",
                    [$req->state]
                )->paginate(100);
3

1 Answer 1

1

I was passing an arary inside an array and istead of where i wrote whereIn

$data = tbl_company::where(
                    "state",
                    [$req->state] //passing array inside an array
                )->paginate(100);

Answer

$data = tbl_company::query()
                ->whereIn(
                    "state",
                    $req->state
                )->paginate(100);
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.