diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 1d3c37dab8..362e9c7141 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -34,6 +34,11 @@ class UsersController extends Controller 'users.jobtitle', 'users.email', 'users.phone', + 'users.address', + 'users.city', + 'users.state', + 'users.country', + 'users.zip', 'users.username', 'users.location_id', 'users.manager_id', @@ -98,7 +103,8 @@ 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', 'phone' + 'consumables_count', 'accessories_count', 'phone', 'address', 'city', 'state', + 'country', 'zip' ]; $sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name'; diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 45794f6c45..354fd17765 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -119,6 +119,11 @@ class UsersController extends Controller $user->company_id = Company::getIdForUser($request->input('company_id', null)); $user->manager_id = $request->input('manager_id', null); $user->notes = $request->input('notes'); + $user->address = $request->input('address', null); + $user->city = $request->input('city', null); + $user->state = $request->input('state', null); + $user->country = $request->input('country', null); + $user->zip = $request->input('zip', null); // Strip out the superuser permission if the user isn't a superadmin $permissions_array = $request->input('permission'); @@ -312,13 +317,19 @@ class UsersController extends Controller $user->locale = $request->input('locale'); $user->employee_num = $request->input('employee_num'); $user->activated = $request->input('activated', $user->activated); - $user->jobtitle = $request->input('jobtitle'); + $user->jobtitle = $request->input('jobtitle', null); $user->phone = $request->input('phone'); $user->location_id = $request->input('location_id', null); $user->company_id = Company::getIdForUser($request->input('company_id', null)); $user->manager_id = $request->input('manager_id', null); $user->notes = $request->input('notes'); $user->department_id = $request->input('department_id', null); + $user->address = $request->input('address', null); + $user->city = $request->input('city', null); + $user->state = $request->input('state', null); + $user->country = $request->input('country', null); + $user->zip = $request->input('zip', null); + // Do we want to update the user password? diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 8b283da8d0..8d9bab60ff 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -35,6 +35,11 @@ class UsersTransformer ] : null, 'jobtitle' => ($user->jobtitle) ? e($user->jobtitle) : null, 'phone' => ($user->phone) ? e($user->phone) : null, + 'address' => ($user->address) ? e($user->address) : null, + 'city' => ($user->city) ? e($user->city) : null, + 'state' => ($user->state) ? e($user->state) : null, + 'country' => ($user->country) ? e($user->country) : null, + 'zip' => ($user->zip) ? e($user->zip) : 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 a9c40a12ed..d4eb84e0e1 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -38,6 +38,11 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo 'phone_number', 'username', 'first_name', + 'address', + 'city', + 'state', + 'country', + 'zip', ]; protected $casts = [ diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index 53b5fcc344..1515a76f6b 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -86,6 +86,46 @@ class UserPresenter extends Presenter "title" => trans('admin/users/table.phone'), "visible" => true, ], + [ + "field" => "address", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('general.address'), + "visible" => false, + ], + [ + "field" => "city", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('general.city'), + "visible" => false, + ], + [ + "field" => "state", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('general.state'), + "visible" => false, + ], + [ + "field" => "country", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('general.country'), + "visible" => false, + ], + [ + "field" => "zip", + "searchable" => true, + "sortable" => true, + "switchable" => true, + "title" => trans('general.zip'), + "visible" => false, + ], [ "field" => "username", "searchable" => true, diff --git a/database/migrations/2017_10_30_182938_add_address_to_user.php b/database/migrations/2017_10_30_182938_add_address_to_user.php new file mode 100644 index 0000000000..91d7283dd2 --- /dev/null +++ b/database/migrations/2017_10_30_182938_add_address_to_user.php @@ -0,0 +1,39 @@ +string('address')->nullable()->default(null); + $table->string('city')->nullable()->default(null); + $table->string('state', 3)->nullable()->default(null); + $table->string('zip', 10)->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('address'); + $table->dropColumn('city'); + $table->dropColumn('state'); + $table->dropColumn('zip'); + + }); + } +} diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 277a17e209..f353eef0b4 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -276,6 +276,53 @@ + +