Reputation: 257
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);
Upvotes: 1
Views: 1016
Reputation: 257
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);
Upvotes: 1