Allow user to set country

This commit is contained in:
Nabeel Shahzad
2018-01-09 19:08:16 -06:00
parent af646ff8d8
commit 78912f2f31
8 changed files with 38 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ class CreateUsersTable extends Migration
$table->string('api_key', 40)->nullable();
$table->unsignedInteger('airline_id');
$table->unsignedInteger('rank_id')->nullable();
$table->string('country', 2)->nullable();
$table->string('home_airport_id', 5)->nullable();
$table->string('curr_airport_id', 5)->nullable();
$table->string('last_pirep_id', 12)->nullable();

View File

@@ -16,6 +16,7 @@ users:
api_key: testadminapikey
airline_id: 1
rank_id: 1
country: us
home_airport_id: KAUS
curr_airport_id: KJFK
last_pirep_id: pirepid_3

View File

@@ -136,9 +136,15 @@ class UserController extends BaseController
->whereOrder(['user_id' => $id], 'created_at', 'desc')
->paginate();
$countries = collect((new \League\ISO3166\ISO3166)->all())
->mapWithKeys(function ($item, $key) {
return [strtolower($item['alpha2']) => $item['name']];
});
return view('admin.users.edit', [
'user' => $user,
'pireps' => $pireps,
'countries' => $countries,
'timezones' => Timezonelist::toArray(),
'airports' => Airport::all()->pluck('icao', 'id'),
'airlines' => Airline::all()->pluck('name', 'id'),

View File

@@ -73,10 +73,16 @@ class ProfileController extends AppBaseController
$airlines = $this->airlineRepo->selectBoxList();
$airports = $this->airportRepo->selectBoxList();
$countries = collect((new \League\ISO3166\ISO3166)->all())
->mapWithKeys(function($item, $key) {
return [strtolower($item['alpha2']) => $item['name']];
});
return $this->view('profile.edit', [
'user' => $user,
'airlines' => $airlines,
'airports' => $airports,
'countries' => $countries,
'timezones' => Timezonelist::toArray(),
]);
}

View File

@@ -37,6 +37,7 @@ class User extends Authenticatable
'airline_id',
'rank_id',
'api_key',
'country',
'home_airport_id',
'curr_airport_id',
'last_pirep_id',

View File

@@ -10,15 +10,21 @@
</div>
<div class="form-group col-sm-4">
{!! Form::label('timezone', 'Timezone:') !!}
{!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!}
{!! Form::label('password', 'Password:') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
</div>
</div>
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('password', 'Password:') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
<div class="form-group">
{!! Form::label('country', 'Country:') !!} <br />
{!! Form::select('country', $countries, null, ['class' => 'select2' ]); !!}
</div>
<div class="form-group">
{!! Form::label('timezone', 'Timezone:') !!} <br/>
{!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!}
</div>
</div>
<div class="form-group col-sm-6">
{!! Form::label('home_airport_id', 'Home Airport:') !!}

View File

@@ -37,6 +37,18 @@
</td>
</tr>
<tr>
<td>Country</td>
<td>
<div class="input-group form-group-no-border{{ $errors->has('country') ? ' has-danger' : '' }}">
{!! Form::select('country', $countries, null, ['class' => 'form-control select2' ]); !!}
</div>
@if ($errors->has('country'))
<p class="text-danger">{{ $errors->first('country') }}</p>
@endif
</td>
</tr>
<tr>
<td>Timezone</td>
<td>

View File

@@ -7,6 +7,7 @@
<img src="{!! public_asset('/assets/frontend/img/logo.svg') !!}" alt="">
</div>
<h3 class="title">{!! $user->name !!}</h3>
<h6><span class="flag-icon flag-icon-{!! $user->country !!}"></span></h6>
<h6>{!! $user->pilot_id !!}</h6>
<h6>{!! $user->rank->name !!}</h6>
<p class="description" style="color: #9A9A9A;">