Support the ongoing development of Laravel.io →
Database Eloquent Installation
Last updated 2 years ago.
0
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)) {

0

Sign in to participate in this thread!

Eventy

Your banner here too?

sonesay sonesay Joined 1 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.