diff --git a/CHANGELOG.md b/CHANGELOG.md index 43bce828..126b69c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### Added * Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot. * New button in file manager that triggers the right click menu to enable support on mobile devices and those who cannot right click (blessed be them). +* Support for filtering users when listing all users on the system. ### Changed * File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached. diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 18ec6f1a..8fc403ec 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -51,8 +51,33 @@ class UserController extends Controller public function getIndex(Request $request) { + $query = User::select('users.*'); + if ($request->input('filter') && !is_null($request->input('filter'))) { + preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches); + foreach($matches[0] as $match) { + $match = str_replace('"', '', $match); + if (strpos($match, ':')) { + list($field, $term) = explode(':', $match); + $query->orWhere($field, 'LIKE', '%' . $term . '%'); + } else { + $query->where('email', 'LIKE', '%' . $match . '%'); + $query->orWhere([ + ['uuid', 'LIKE', '%' . $match . '%'], + ['root_admin', 'LIKE', '%' . $match . '%'] + ]); + } + } + } + + try { + $users = $query->paginate(20); + } catch (\Exception $ex) { + Alert::warning('There was an error with the search parameters provided.'); + $users = User::all()->paginate(20); + } + return view('admin.users.index', [ - 'users' => User::paginate(20) + 'users' => $users ]); } diff --git a/resources/views/admin/users/index.blade.php b/resources/views/admin/users/index.blade.php index 4092caa6..04eaaf20 100644 --- a/resources/views/admin/users/index.blade.php +++ b/resources/views/admin/users/index.blade.php @@ -31,6 +31,14 @@
  • Accounts
  • All Registered Users


    +
    +
    + +
    + +
    +
    +