From fc644925ea55d017823926438a0748d5b34a41d4 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 23 Oct 2017 14:21:51 -0700 Subject: [PATCH] Fixes #4291 - adds phone to user listing --- app/Http/Controllers/Api/UsersController.php | 3 ++- app/Http/Transformers/UsersTransformer.php | 1 + app/Models/User.php | 1 + app/Presenters/UserPresenter.php | 8 ++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 7ae2e20d22..eb93f802f3 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -31,6 +31,7 @@ class UsersController extends Controller 'users.two_factor_enrolled', 'users.jobtitle', 'users.email', + 'users.phone', 'users.username', 'users.location_id', 'users.manager_id', @@ -93,7 +94,7 @@ class UsersController extends Controller 'last_name','first_name','email','jobtitle','username','employee_num', 'assets','accessories', 'consumables','licenses','groups','activated','created_at', 'two_factor_enrolled','two_factor_optin','last_login', 'assets_count', 'licenses_count', - 'consumables_count', 'accessories_count' + 'consumables_count', 'accessories_count', 'phone' ]; $sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name'; diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 2db1d1c801..3f8d99489d 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -33,6 +33,7 @@ class UsersTransformer 'name'=> e($user->manager->username) ] : null, 'jobtitle' => ($user->jobtitle) ? e($user->jobtitle) : null, + 'phone' => ($user->phone) ? e($user->phone) : null, 'email' => e($user->email), 'department' => ($user->department) ? [ 'id' => (int) $user->department->id, diff --git a/app/Models/User.php b/app/Models/User.php index 0639865a88..5df4a81ef6 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -403,6 +403,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo ->orWhere('users.email', 'LIKE', "%$search%") ->orWhere('users.username', 'LIKE', "%$search%") ->orWhere('users.notes', 'LIKE', "%$search%") + ->orWhere('users.phone', 'LIKE', "%$search%") ->orWhere('users.jobtitle', 'LIKE', "%$search%") ->orWhere('users.employee_num', 'LIKE', "%$search%") ->orWhere(function ($query) use ($search) { diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index 5ff2f0d179..0b88e09085 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -69,6 +69,14 @@ class UserPresenter extends Presenter "visible" => true, "formatter" => "emailFormatter" ], + [ + "field" => "phone", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('admin/users/table.phone'), + "visible" => true, + ], [ "field" => "username", "searchable" => true,