mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Added address for users - fixes #4323
This commit is contained in:
parent
0fd0e3a8b4
commit
4eee7f8d97
|
@ -34,6 +34,11 @@ class UsersController extends Controller
|
||||||
'users.jobtitle',
|
'users.jobtitle',
|
||||||
'users.email',
|
'users.email',
|
||||||
'users.phone',
|
'users.phone',
|
||||||
|
'users.address',
|
||||||
|
'users.city',
|
||||||
|
'users.state',
|
||||||
|
'users.country',
|
||||||
|
'users.zip',
|
||||||
'users.username',
|
'users.username',
|
||||||
'users.location_id',
|
'users.location_id',
|
||||||
'users.manager_id',
|
'users.manager_id',
|
||||||
|
@ -98,7 +103,8 @@ class UsersController extends Controller
|
||||||
'last_name','first_name','email','jobtitle','username','employee_num',
|
'last_name','first_name','email','jobtitle','username','employee_num',
|
||||||
'assets','accessories', 'consumables','licenses','groups','activated','created_at',
|
'assets','accessories', 'consumables','licenses','groups','activated','created_at',
|
||||||
'two_factor_enrolled','two_factor_optin','last_login', 'assets_count', 'licenses_count',
|
'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';
|
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
|
||||||
|
|
|
@ -119,6 +119,11 @@ class UsersController extends Controller
|
||||||
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
||||||
$user->manager_id = $request->input('manager_id', null);
|
$user->manager_id = $request->input('manager_id', null);
|
||||||
$user->notes = $request->input('notes');
|
$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
|
// Strip out the superuser permission if the user isn't a superadmin
|
||||||
$permissions_array = $request->input('permission');
|
$permissions_array = $request->input('permission');
|
||||||
|
@ -312,13 +317,19 @@ class UsersController extends Controller
|
||||||
$user->locale = $request->input('locale');
|
$user->locale = $request->input('locale');
|
||||||
$user->employee_num = $request->input('employee_num');
|
$user->employee_num = $request->input('employee_num');
|
||||||
$user->activated = $request->input('activated', $user->activated);
|
$user->activated = $request->input('activated', $user->activated);
|
||||||
$user->jobtitle = $request->input('jobtitle');
|
$user->jobtitle = $request->input('jobtitle', null);
|
||||||
$user->phone = $request->input('phone');
|
$user->phone = $request->input('phone');
|
||||||
$user->location_id = $request->input('location_id', null);
|
$user->location_id = $request->input('location_id', null);
|
||||||
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
||||||
$user->manager_id = $request->input('manager_id', null);
|
$user->manager_id = $request->input('manager_id', null);
|
||||||
$user->notes = $request->input('notes');
|
$user->notes = $request->input('notes');
|
||||||
$user->department_id = $request->input('department_id', null);
|
$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?
|
// Do we want to update the user password?
|
||||||
|
|
|
@ -35,6 +35,11 @@ class UsersTransformer
|
||||||
] : null,
|
] : null,
|
||||||
'jobtitle' => ($user->jobtitle) ? e($user->jobtitle) : null,
|
'jobtitle' => ($user->jobtitle) ? e($user->jobtitle) : null,
|
||||||
'phone' => ($user->phone) ? e($user->phone) : 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),
|
'email' => e($user->email),
|
||||||
'department' => ($user->department) ? [
|
'department' => ($user->department) ? [
|
||||||
'id' => (int) $user->department->id,
|
'id' => (int) $user->department->id,
|
||||||
|
|
|
@ -38,6 +38,11 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||||
'phone_number',
|
'phone_number',
|
||||||
'username',
|
'username',
|
||||||
'first_name',
|
'first_name',
|
||||||
|
'address',
|
||||||
|
'city',
|
||||||
|
'state',
|
||||||
|
'country',
|
||||||
|
'zip',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
|
|
@ -86,6 +86,46 @@ class UserPresenter extends Presenter
|
||||||
"title" => trans('admin/users/table.phone'),
|
"title" => trans('admin/users/table.phone'),
|
||||||
"visible" => true,
|
"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",
|
"field" => "username",
|
||||||
"searchable" => true,
|
"searchable" => true,
|
||||||
|
|
|
@ -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');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -276,6 +276,53 @@
|
||||||
</div>
|
</div>
|
||||||
</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 -->
|
<!-- Activation Status -->
|
||||||
<div class="form-group {{ $errors->has('activated') ? 'has-error' : '' }}">
|
<div class="form-group {{ $errors->has('activated') ? 'has-error' : '' }}">
|
||||||
<label class="col-md-3 control-label" for="activated">{{ trans('admin/users/table.activated') }}</label>
|
<label class="col-md-3 control-label" for="activated">{{ trans('admin/users/table.activated') }}</label>
|
||||||
|
|
Loading…
Reference in a new issue