From cd61c999e7958f528013e731c055c5c553e343ea Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Tue, 23 Jan 2018 21:58:13 -0600 Subject: [PATCH] Cleanup default value field migrations; flight fields --- .../2017_06_08_0000_create_users_table.php | 6 +++--- .../2017_06_08_191703_create_airlines_table.php | 4 ++-- .../2017_06_09_010621_create_aircrafts_table.php | 2 +- .../2017_06_10_040335_create_fares_table.php | 6 +++--- .../2017_06_11_135707_create_airports_table.php | 10 +++++----- .../2017_06_17_214650_create_flight_tables.php | 4 ++-- .../2017_06_21_165410_create_ranks_table.php | 6 +++--- .../2017_06_28_195426_create_pirep_tables.php | 4 ++-- .../2017_12_20_004147_create_navdata_tables.php | 4 ++-- .../2017_12_20_005147_create_acars_tables.php | 4 ++-- app/Http/Resources/PirepComment.php | 12 ++++++------ app/Models/Flight.php | 4 ++++ resources/views/admin/flights/fields.blade.php | 4 ++++ 13 files changed, 39 insertions(+), 31 deletions(-) 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 2f04b664..54783b7a 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 @@ -26,11 +26,11 @@ class CreateUsersTable extends Migration $table->string('curr_airport_id', 5)->nullable(); $table->string('last_pirep_id', 12)->nullable(); $table->unsignedBigInteger('flights')->default(0); - $table->unsignedBigInteger('flight_time')->default(0); + $table->unsignedBigInteger('flight_time')->nullable()->default(0); $table->decimal('balance', 19)->nullable(); $table->string('timezone', 64)->nullable(); - $table->unsignedTinyInteger('status')->default(0); - $table->unsignedTinyInteger('state')->default(0); + $table->unsignedTinyInteger('status')->nullable()->default(0); + $table->unsignedTinyInteger('state')->nullable()->default(0); $table->boolean('active')->nullable(); $table->ipAddress('last_ip')->nullable(); $table->rememberToken(); diff --git a/app/Database/migrations/2017_06_08_191703_create_airlines_table.php b/app/Database/migrations/2017_06_08_191703_create_airlines_table.php index a7180a23..da8f85cf 100644 --- a/app/Database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/app/Database/migrations/2017_06_08_191703_create_airlines_table.php @@ -21,8 +21,8 @@ class CreateAirlinesTable extends Migration $table->string('country', 2)->nullable(); $table->string('logo', 255)->nullable(); $table->boolean('active')->default(true); - $table->unsignedBigInteger('total_flights')->default(0); - $table->unsignedBigInteger('total_time')->default(0); + $table->unsignedBigInteger('total_flights')->nullable()->default(0); + $table->unsignedBigInteger('total_time')->nullable()->default(0); $table->timestamps(); $table->index('icao'); diff --git a/app/Database/migrations/2017_06_09_010621_create_aircrafts_table.php b/app/Database/migrations/2017_06_09_010621_create_aircrafts_table.php index 9e5b341c..a802959a 100644 --- a/app/Database/migrations/2017_06_09_010621_create_aircrafts_table.php +++ b/app/Database/migrations/2017_06_09_010621_create_aircrafts_table.php @@ -19,7 +19,7 @@ class CreateAircraftsTable extends Migration $table->string('name', 50); $table->string('registration', 10)->nullable(); $table->string('tail_number', 10)->nullable(); - $table->unsignedBigInteger('flight_time')->default(0); + $table->unsignedBigInteger('flight_time')->nullable()->default(0); $table->boolean('active')->default(true); $table->unsignedTinyInteger('state')->default(AircraftState::PARKED); $table->timestamps(); diff --git a/app/Database/migrations/2017_06_10_040335_create_fares_table.php b/app/Database/migrations/2017_06_10_040335_create_fares_table.php index f812096d..3efb6ff2 100644 --- a/app/Database/migrations/2017_06_10_040335_create_fares_table.php +++ b/app/Database/migrations/2017_06_10_040335_create_fares_table.php @@ -17,9 +17,9 @@ class CreateFaresTable extends Migration $table->increments('id'); $table->string('code', 50); $table->string('name', 50); - $table->unsignedDecimal('price', 19)->default(0.00); - $table->unsignedDecimal('cost', 19)->default(0.00); - $table->unsignedInteger('capacity')->default(0); + $table->unsignedDecimal('price', 19)->nullable()->default(0.00); + $table->unsignedDecimal('cost', 19)->nullable()->default(0.00); + $table->unsignedInteger('capacity')->nullable()->default(0); $table->string('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); diff --git a/app/Database/migrations/2017_06_11_135707_create_airports_table.php b/app/Database/migrations/2017_06_11_135707_create_airports_table.php index 3b99e9a5..f2c8c3f3 100644 --- a/app/Database/migrations/2017_06_11_135707_create_airports_table.php +++ b/app/Database/migrations/2017_06_11_135707_create_airports_table.php @@ -16,11 +16,11 @@ class CreateAirportsTable extends Migration $table->string('country', 64)->nullable(); $table->string('tz', 64)->nullable(); $table->boolean('hub')->default(false); - $table->unsignedDecimal('fuel_100ll_cost', 19)->default(0); - $table->unsignedDecimal('fuel_jeta_cost', 19)->default(0); - $table->unsignedDecimal('fuel_mogas_cost', 19)->default(0); - $table->float('lat', 7, 4)->default(0.0)->nullable(); - $table->float('lon', 7, 4)->default(0.0)->nullable(); + $table->unsignedDecimal('fuel_100ll_cost', 19)->nullable()->default(0); + $table->unsignedDecimal('fuel_jeta_cost', 19)->nullable()->default(0); + $table->unsignedDecimal('fuel_mogas_cost', 19)->nullable()->default(0); + $table->float('lat', 7, 4)->nullable()->default(0.0); + $table->float('lon', 7, 4)->nullable()->default(0.0); }); } diff --git a/app/Database/migrations/2017_06_17_214650_create_flight_tables.php b/app/Database/migrations/2017_06_17_214650_create_flight_tables.php index df0872d2..81e97ede 100644 --- a/app/Database/migrations/2017_06_17_214650_create_flight_tables.php +++ b/app/Database/migrations/2017_06_17_214650_create_flight_tables.php @@ -24,8 +24,8 @@ class CreateFlightTables extends Migration $table->string('alt_airport_id', 5)->nullable(); $table->string('dpt_time', 10)->nullable(); $table->string('arr_time', 10)->nullable(); - $table->unsignedInteger('level')->default(0); - $table->unsignedDecimal('distance', 19)->default(0.0); + $table->unsignedInteger('level')->nullable()->default(0); + $table->unsignedDecimal('distance', 19)->nullable()->default(0.0); $table->unsignedDecimal('flight_time', 19)->nullable(); $table->text('route')->nullable(); $table->text('notes')->nullable(); diff --git a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php index 51ce74fe..637c98c7 100644 --- a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php +++ b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php @@ -18,9 +18,9 @@ class CreateRanksTable extends Migration $table->string('name', 50); $table->string('image_link')->nullable(); $table->unsignedInteger('hours')->default(0); - $table->boolean('auto_approve_acars')->default(false); - $table->boolean('auto_approve_manual')->default(false); - $table->boolean('auto_promote')->default(true); + $table->boolean('auto_approve_acars')->nullable()->default(false); + $table->boolean('auto_approve_manual')->nullable()->default(false); + $table->boolean('auto_promote')->nullable()->default(true); $table->timestamps(); $table->unique('name'); diff --git a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php index 57f72cb5..9b97c709 100644 --- a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php +++ b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php @@ -35,7 +35,7 @@ class CreatePirepTables extends Migration $table->unsignedDecimal('fuel_used', 19)->nullable(); $table->text('route')->nullable(); $table->text('notes')->nullable(); - $table->unsignedTinyInteger('source')->default(0); + $table->unsignedTinyInteger('source')->nullable()->default(0); $table->tinyInteger('state')->default(PirepState::PENDING); $table->tinyInteger('status')->default(PirepStatus::SCHEDULED); $table->longText('raw_data')->nullable(); @@ -85,7 +85,7 @@ class CreatePirepTables extends Migration $table->bigIncrements('id'); $table->string('name', 50); $table->string('slug', 50)->nullable(); - $table->boolean('required')->default(false); + $table->boolean('required')->nullable()->default(false); }); Schema::create('pirep_field_values', function (Blueprint $table) { diff --git a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php index 96d00448..caddd7a5 100644 --- a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php +++ b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php @@ -21,8 +21,8 @@ class CreateNavdataTables extends Migration $table->string('id', 5); $table->string('name', 24); $table->unsignedInteger('type'); - $table->float('lat', 7, 4)->default(0.0); - $table->float('lon', 7, 4)->default(0.0); + $table->float('lat', 7, 4)->nullable()->default(0.0); + $table->float('lon', 7, 4)->nullable()->default(0.0); $table->string('freq', 7)->nullable(); $table->primary(['id', 'name']); diff --git a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php index 684297ce..238aa3ae 100644 --- a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php +++ b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php @@ -21,8 +21,8 @@ class CreateAcarsTables extends Migration $table->unsignedInteger('order')->default(0); $table->string('name')->nullable(); $table->string('log')->nullable(); - $table->float('lat', 7, 4)->default(0.0); - $table->float('lon', 7, 4)->default(0.0); + $table->float('lat', 7, 4)->nullable()->default(0.0); + $table->float('lon', 7, 4)->nullable()->default(0.0); $table->unsignedInteger('heading')->nullable(); $table->unsignedInteger('altitude')->nullable(); $table->integer('vs')->nullable(); diff --git a/app/Http/Resources/PirepComment.php b/app/Http/Resources/PirepComment.php index 9783e8ad..056f91d8 100644 --- a/app/Http/Resources/PirepComment.php +++ b/app/Http/Resources/PirepComment.php @@ -22,13 +22,13 @@ class PirepComment extends Resource $user = $this->user; return [ - 'id' => $this->id, - 'comment' => $this->comment, - 'created_at' => $this->created_at, + 'id' => $this->id, + 'comment' => $this->comment, + 'created_at' => $this->created_at, 'user' => [ - 'id' => $user->id, - 'pilot_id' => $user->pilot_id, - 'name' => $user->name, + 'id' => $user->id, + 'pilot_id' => $user->pilot_id, + 'name' => $user->name, ], ]; } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 3cc888ad..de67f2ff 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -40,9 +40,13 @@ class Flight extends BaseModel ]; public static $rules = [ + 'airline_id' => 'required|exists:airlines,id', 'flight_number' => 'required', + 'route_code' => 'nullable', + 'route_leg' => 'nullable', 'dpt_airport_id' => 'required', 'arr_airport_id' => 'required', + 'level' => 'nullable', ]; /** diff --git a/resources/views/admin/flights/fields.blade.php b/resources/views/admin/flights/fields.blade.php index c730a6ba..1d1adcfd 100644 --- a/resources/views/admin/flights/fields.blade.php +++ b/resources/views/admin/flights/fields.blade.php @@ -17,12 +17,14 @@
{!! Form::label('route_code', 'Route Code:') !!} {!! Form::text('route_code', null, ['class'=>'form-control', 'placeholder'=>'optional']) !!} +

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

{!! Form::label('route_leg', 'Route Leg:') !!} {!! Form::text('route_leg', null, ['class'=>'form-control', 'placeholder'=>'optional']) !!} +

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

@@ -69,11 +71,13 @@ SAME ROW
{!! Form::label('distance', 'Distance:') !!} {!! Form::text('distance', null, ['class' => 'form-control']) !!} +

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

{!! Form::label('level', 'Flight Level:') !!} {!! Form::text('level', null, ['class' => 'form-control']) !!} +

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