
When I am trying to put some value in my input search box and after pressing enter button showing above issue.
But when I am trying to filter data with my search button then it’s working fine. so i dig into it. i found one solution on it.
FilterController.php
$users = DB::table('users')
->where(function($query) use ($countryId, $stateId, $cityId) {
if (isset($countryId) && $countryId !== null && $countryId !== '' && $stateId == 'Select State') {
$query->where('country_id', '=', $countryId);
}
if (isset($countryId) && $countryId !== null && $countryId !== '' && isset($stateId) && $stateId !== 'Select State' && $stateId !== '') {
$query->where([
['country_id', '=', $countryId],
['state_id', '<>', $stateId]
]);
}
})->get()->paginate(5);
Solution :
Just remove the get() and your code will work fine.
$users = DB::table('users')
->where(function($query) use ($countryId, $stateId, $cityId) {
if (isset($countryId) && $countryId !== null && $countryId !== '' && $stateId == 'Select State') {
$query->where('country_id', '=', $countryId);
}
if (isset($countryId) && $countryId !== null && $countryId !== '' && isset($stateId) && $stateId !== 'Select State' && $stateId !== '') {
$query->where([
['country_id', '=', $countryId],
['state_id', '<>', $stateId]
]);
}
})->paginate(5);
References :
Latest posts by Chandan Kumar (see all)
- How to share files between two computers? - June 5, 2021
- 302 Found: What It Is and How to Fix It? - May 25, 2021
- Laravel 5.5 Method paginate does not exist - May 15, 2021