Cleanup default value field migrations; flight fields

This commit is contained in:
Nabeel Shahzad 2018-01-23 21:58:13 -06:00
parent 9964eb63fb
commit cd61c999e7
13 changed files with 39 additions and 31 deletions

View File

@ -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();

View File

@ -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');

View File

@ -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();

View File

@ -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();

View File

@ -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);
});
}

View File

@ -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();

View File

@ -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');

View File

@ -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) {

View File

@ -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']);

View File

@ -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();

View File

@ -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,
],
];
}

View File

@ -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',
];
/**

View File

@ -17,12 +17,14 @@
<div class="form-group col-sm-3">
{!! Form::label('route_code', 'Route Code:') !!}
{!! Form::text('route_code', null, ['class'=>'form-control', 'placeholder'=>'optional']) !!}
<p class="text-danger">{{ $errors->first('route_code') }}</p>
</div>
<!-- Route Leg Field -->
<div class="form-group col-sm-3">
{!! Form::label('route_leg', 'Route Leg:') !!}
{!! Form::text('route_leg', null, ['class'=>'form-control', 'placeholder'=>'optional']) !!}
<p class="text-danger">{{ $errors->first('route_leg') }}</p>
</div>
</div>
@ -69,11 +71,13 @@ SAME ROW
<div class="form-group col-sm-3">
{!! Form::label('distance', 'Distance:') !!}
{!! Form::text('distance', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('distance') }}</p>
</div>
<div class="form-group col-sm-3">
{!! Form::label('level', 'Flight Level:') !!}
{!! Form::text('level', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('level') }}</p>
</div>
</div>