diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 5c3c9a80861b..2e1cc1eb20fe 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -845,7 +845,8 @@ public function getDatatable($status = null) $sort = e(Input::get('sort')); } - $users = User::select('users.*')->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'sentryThrottle', 'groups', 'userloc'); + $users = User::select(array('users.id','users.email','users.username','users.location_id','users.manager_id','users.first_name','users.last_name','users.created_at')) + ->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'sentryThrottle', 'groups', 'userloc'); switch ($status) { case 'deleted': diff --git a/app/models/User.php b/app/models/User.php index fd205c2f0a36..4d629d542fe1 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -212,11 +212,11 @@ public function scopeTextsearch($query, $search) { return $query->where(function($query) use ($search) { - $query->where('first_name', 'LIKE', "%$search%") - ->orWhere('last_name', 'LIKE', "%$search%") - ->orWhere('email', 'LIKE', "%$search%") - ->orWhere('username', 'LIKE', "%$search%") - ->orWhere('notes', 'LIKE', "%$search%") + $query->where('users.first_name', 'LIKE', "%$search%") + ->orWhere('users.last_name', 'LIKE', "%$search%") + ->orWhere('users.email', 'LIKE', "%$search%") + ->orWhere('users.username', 'LIKE', "%$search%") + ->orWhere('users.notes', 'LIKE', "%$search%") ->orWhere(function($query) use ($search) { $query->whereHas('userloc', function($query) use ($search) { $query->where('name','LIKE','%'.$search.'%'); @@ -225,7 +225,7 @@ public function scopeTextsearch($query, $search) // Ugly, ugly code because Laravel sucks at self-joins ->orWhere(function($query) use ($search) { - $query->whereRaw("manager_id IN (select id from users where first_name LIKE '%".$search."%' OR last_name LIKE '%".$search."%') "); + $query->whereRaw("users.manager_id IN (select id from users where first_name LIKE '%".$search."%' OR last_name LIKE '%".$search."%') "); }); });