Fix timezone/country not being saved on register #223

This commit is contained in:
Nabeel Shahzad 2018-04-03 09:43:32 -05:00
parent 04d63ca931
commit 99555539a7
2 changed files with 20 additions and 10 deletions

View File

@ -9,6 +9,7 @@ use App\Models\User;
use App\Repositories\AirlineRepository; use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository; use App\Repositories\AirportRepository;
use App\Services\UserService; use App\Services\UserService;
use App\Support\Countries;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@ -64,6 +65,7 @@ class RegisterController extends Controller
return view('auth.register', [ return view('auth.register', [
'airports' => $airports, 'airports' => $airports,
'airlines' => $airlines, 'airlines' => $airlines,
'countries' => Countries::getSelectList(),
'timezones' => Timezonelist::toArray(), 'timezones' => Timezonelist::toArray(),
]); ]);
} }
@ -99,15 +101,13 @@ class RegisterController extends Controller
*/ */
protected function create(array $data) protected function create(array $data)
{ {
$opts = [ // Default options
'name' => $data['name'], $opts = array_merge([
'email' => $data['email'], 'api_key' => Utils::generateApiKey(),
'api_key' => Utils::generateApiKey(), ], $data);
'airline_id' => $data['airline_id'],
'home_airport_id' => $data['home_airport_id'], $opts['curr_airport_id'] = $data['home_airport_id'];
'curr_airport_id' => $data['home_airport_id'], $opts['password'] = Hash::make($data['password']);
'password' => Hash::make($data['password'])
];
$user = User::create($opts); $user = User::create($opts);
$user = $this->userService->createPilot($user); $user = $this->userService->createPilot($user);
@ -130,7 +130,9 @@ class RegisterController extends Controller
'email' => 'required|email|unique:users,email', 'email' => 'required|email|unique:users,email',
'airline_id' => 'required', 'airline_id' => 'required',
'home_airport_id' => 'required', 'home_airport_id' => 'required',
'password' => 'required|confirmed' 'password' => 'required|confirmed',
'timezone' => 'required',
'country' => 'required',
]; ];
if (config('captcha.enabled')) { if (config('captcha.enabled')) {

View File

@ -43,6 +43,14 @@
<p class="text-danger">{{ $errors->first('home_airport_id') }}</p> <p class="text-danger">{{ $errors->first('home_airport_id') }}</p>
@endif @endif
<label for="country" class="control-label">Country</label>
<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
<label for="timezone" class="control-label">Timezone</label> <label for="timezone" class="control-label">Timezone</label>
<div class="input-group form-group-no-border {{ $errors->has('timezone') ? 'has-danger' : '' }}"> <div class="input-group form-group-no-border {{ $errors->has('timezone') ? 'has-danger' : '' }}">
{{ Form::select('timezone', $timezones, null, ['id'=>'timezone', 'class' => 'form-control select2' ]) }} {{ Form::select('timezone', $timezones, null, ['id'=>'timezone', 'class' => 'form-control select2' ]) }}