WhereIn issue in query - laravel 5.2
I have query like
if($request->has('compare_ids'))
{
$listings = Property::with('images','location','sublocation')
->whereIn('id',array($request->compare_ids))
->get();
}
When i check querylog, it shows like
Array
(
[0] => Array
(
[query] => select * from `listings` where `id` in (?)
[bindings] => Array
(
[0] => 1,5,6
)
[time] => 1.32
)
I have these three ids in table but still it shows only one record.When i check
{{ count($compareList) }}
It give me 1.
What is value of $request->compare_ids? Is this a string or an array?
If it's an array then you make it a double array and it won't work.
If it's a string you need to make an array of it
->whereIn('id', explode(',', $request->compare_ids))
Please or to participate in this conversation.