public function getSearch($request)
{
$search = $request['search'] ? $request['search'] : '';
$active = $request['active'] ? $request['active'] : 0;
if (isset($search) || isset($active)) {
return ExUser::where(function ($query) use ($active, $search){
$query = $query->where('name', 'LIKE', '%' . $search . '%')
->orWhere('gecos', 'LIKE', '%' . $search . '%')
->orWhere('email', 'LIKE', '%' . $search . '%')
->orWhere('uid', 'LIKE', '%' . $search . '%')
->orderBy('uid', 'DESC');
if ($active) {
$query = $query->where('active', 1);
}
return $query;
})->paginate(100);
}
}
Also in your code i don't understand why you're doing this, this will always return true:
if (isset($search) || isset($active)) {
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community