diff --git a/app/Database/migrations/2017_06_08_0000_create_users_table.php b/app/Database/migrations/2017_06_08_0000_create_users_table.php index 94a47f4a..2f04b664 100755 --- a/app/Database/migrations/2017_06_08_0000_create_users_table.php +++ b/app/Database/migrations/2017_06_08_0000_create_users_table.php @@ -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(); diff --git a/app/Database/seeds/sample.yml b/app/Database/seeds/sample.yml index 16637918..42224afd 100644 --- a/app/Database/seeds/sample.yml +++ b/app/Database/seeds/sample.yml @@ -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 diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 7c3db522..ce337acc 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -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'), diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index e619b25f..d3e0d133 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -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(), ]); } diff --git a/app/Models/User.php b/app/Models/User.php index bd85eeac..a4f46c1b 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -37,6 +37,7 @@ class User extends Authenticatable 'airline_id', 'rank_id', 'api_key', + 'country', 'home_airport_id', 'curr_airport_id', 'last_pirep_id', diff --git a/resources/views/admin/users/fields.blade.php b/resources/views/admin/users/fields.blade.php index 29dd58ff..6dd7b43e 100644 --- a/resources/views/admin/users/fields.blade.php +++ b/resources/views/admin/users/fields.blade.php @@ -10,15 +10,21 @@
- {!! Form::label('timezone', 'Timezone:') !!} - {!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!} + {!! Form::label('password', 'Password:') !!} + {!! Form::password('password', ['class' => 'form-control']) !!}
- {!! Form::label('password', 'Password:') !!} - {!! Form::password('password', ['class' => 'form-control']) !!} +
+ {!! Form::label('country', 'Country:') !!}
+ {!! Form::select('country', $countries, null, ['class' => 'select2' ]); !!} +
+
+ {!! Form::label('timezone', 'Timezone:') !!}
+ {!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!} +
{!! Form::label('home_airport_id', 'Home Airport:') !!} diff --git a/resources/views/layouts/default/profile/fields.blade.php b/resources/views/layouts/default/profile/fields.blade.php index 71377e3d..cc19322b 100644 --- a/resources/views/layouts/default/profile/fields.blade.php +++ b/resources/views/layouts/default/profile/fields.blade.php @@ -37,6 +37,18 @@ + + Country + +
+ {!! Form::select('country', $countries, null, ['class' => 'form-control select2' ]); !!} +
+ @if ($errors->has('country')) +

{{ $errors->first('country') }}

+ @endif + + + Timezone diff --git a/resources/views/layouts/default/profile/index.blade.php b/resources/views/layouts/default/profile/index.blade.php index 2c7cbeb1..fa14dbd7 100644 --- a/resources/views/layouts/default/profile/index.blade.php +++ b/resources/views/layouts/default/profile/index.blade.php @@ -7,6 +7,7 @@

{!! $user->name !!}

+
{!! $user->pilot_id !!}
{!! $user->rank->name !!}