Skip to content

A free open source IT asset/license management system

Added address for users - fixes #4323

snipe4eee7f8d9788
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 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddAddressToUser extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->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 @@
</div>
</div>
+ <!-- Address -->
+ <div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
+ <label class="col-md-3 control-label" for="address">{{ trans('general.address') }}</label>
+ <div class="col-md-4">
+ <input class="form-control" type="text" name="address" id="address" value="{{ Input::old('address', $user->address) }}" />
+ {!! $errors->first('address', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+ <!-- City -->
+ <div class="form-group{{ $errors->has('city') ? ' has-error' : '' }}">
+ <label class="col-md-3 control-label" for="city">{{ trans('general.city') }}</label>
+ <div class="col-md-4">
+ <input class="form-control" type="text" name="city" id="city" value="{{ Input::old('city', $user->city) }}" />
+ {!! $errors->first('city', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+ <!-- State -->
+ <div class="form-group{{ $errors->has('state') ? ' has-error' : '' }}">
+ <label class="col-md-3 control-label" for="state">{{ trans('general.state') }}</label>
+ <div class="col-md-4">
+ <input class="form-control" type="text" name="state" id="state" value="{{ Input::old('state', $user->state) }}" maxlength="3" />
+ {!! $errors->first('state', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+ <!-- Country -->
+ <div class="form-group{{ $errors->has('country') ? ' has-error' : '' }}">
+ <label class="col-md-3 control-label" for="city">{{ trans('general.country') }}</label>
+ <div class="col-md-4">
+ {!! Form::countries('country', Input::old('country', $user->country), 'select2') !!}
+ {!! $errors->first('country', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+ <!-- Zip -->
+ <div class="form-group{{ $errors->has('zip') ? ' has-error' : '' }}">
+ <label class="col-md-3 control-label" for="zip">{{ trans('general.zip') }}</label>
+ <div class="col-md-4">
+ <input class="form-control" type="text" name="zip" id="zip" value="{{ Input::old('zip', $user->zip) }}" maxlength="10" />
+ {!! $errors->first('zip', '<span class="alert-msg">:message</span>') !!}
+ </div>
+ </div>
+
+
+
<!-- Activation Status -->
<div class="form-group {{ $errors->has('activated') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="activated">{{ trans('admin/users/table.activated') }}</label>