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 1622bab1..93fce01b 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 @@ -24,11 +24,11 @@ class CreateUsersTable extends Migration $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(); + $table->string('last_pirep_id', \App\Models\Pirep::ID_MAX_LENGTH)->nullable(); $table->unsignedBigInteger('flights')->default(0); $table->unsignedBigInteger('flight_time')->nullable()->default(0); $table->unsignedBigInteger('transfer_time')->nullable()->default(0); - $table->decimal('balance', 19)->nullable(); + $table->decimal('balance')->nullable(); $table->string('timezone', 64)->nullable(); $table->unsignedTinyInteger('status')->nullable()->default(0); $table->unsignedTinyInteger('state')->nullable()->default(0); 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 c7eb26c5..b53e278a 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 @@ -18,7 +18,7 @@ class CreateAircraftsTable extends Migration $table->string('name', 50); $table->string('registration', 10)->nullable(); $table->string('hex_code', 10)->nullable(); - $table->unsignedDecimal('zfw', 12)->nullable()->default(0); + $table->unsignedDecimal('zfw')->nullable()->default(0); $table->unsignedBigInteger('flight_time')->nullable()->default(0); $table->boolean('active')->default(true); $table->unsignedTinyInteger('state')->default(AircraftState::PARKED); 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 3efb6ff2..525925ce 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,8 +17,8 @@ class CreateFaresTable extends Migration $table->increments('id'); $table->string('code', 50); $table->string('name', 50); - $table->unsignedDecimal('price', 19)->nullable()->default(0.00); - $table->unsignedDecimal('cost', 19)->nullable()->default(0.00); + $table->unsignedDecimal('price')->nullable()->default(0.00); + $table->unsignedDecimal('cost')->nullable()->default(0.00); $table->unsignedInteger('capacity')->nullable()->default(0); $table->string('notes')->nullable(); $table->boolean('active')->default(true); 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 e56aaafc..71feb7f1 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,9 +16,9 @@ class CreateAirportsTable extends Migration $table->string('country', 64)->nullable(); $table->string('timezone', 64)->nullable(); $table->boolean('hub')->default(false); - $table->unsignedDecimal('fuel_100ll_cost', 8)->nullable()->default(0); - $table->unsignedDecimal('fuel_jeta_cost', 8)->nullable()->default(0); - $table->unsignedDecimal('fuel_mogas_cost', 8)->nullable()->default(0); + $table->unsignedDecimal('fuel_100ll_cost')->nullable()->default(0); + $table->unsignedDecimal('fuel_jeta_cost')->nullable()->default(0); + $table->unsignedDecimal('fuel_mogas_cost')->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 5a1b7c31..75bcb679 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 @@ -16,7 +16,7 @@ class CreateFlightTables extends Migration public function up() { Schema::create('flights', function (Blueprint $table) { - $table->string('id', 12); + $table->string('id', \App\Models\Flight::ID_MAX_LENGTH); $table->unsignedInteger('airline_id'); $table->string('flight_number', 10); $table->string('route_code', 5)->nullable(); @@ -27,7 +27,7 @@ class CreateFlightTables extends Migration $table->string('dpt_time', 10)->nullable(); $table->string('arr_time', 10)->nullable(); $table->unsignedInteger('level')->nullable()->default(0); - $table->unsignedDecimal('distance', 19)->nullable()->default(0.0); + $table->unsignedDecimal('distance')->nullable()->default(0.0); $table->unsignedInteger('flight_time')->nullable(); $table->tinyInteger('flight_type')->default(FlightType::PASSENGER); $table->text('route')->nullable(); @@ -38,15 +38,13 @@ class CreateFlightTables extends Migration $table->primary('id'); - #$table->unique('flight_number'); - $table->index('flight_number'); $table->index('dpt_airport_id'); $table->index('arr_airport_id'); }); Schema::create('flight_fare', function (Blueprint $table) { - $table->string('flight_id', 12); + $table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH); $table->unsignedInteger('fare_id'); $table->string('price', 10)->nullable(); $table->string('cost', 10)->nullable(); @@ -58,7 +56,7 @@ class CreateFlightTables extends Migration Schema::create('flight_fields', function (Blueprint $table) { $table->increments('id'); - $table->string('flight_id', 12); + $table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH); $table->string('name', 50); $table->text('value'); $table->timestamps(); diff --git a/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php b/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php index 6cbdeb47..72ade186 100644 --- a/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php +++ b/app/Database/migrations/2017_06_23_011011_create_subfleet_tables.php @@ -19,16 +19,16 @@ class CreateSubfleetTables extends Migration $table->string('name', 50); $table->string('type', 50); $table->unsignedTinyInteger('fuel_type')->nullable(); - $table->unsignedDecimal('cargo_capacity', 19)->nullable(); - $table->unsignedDecimal('fuel_capacity', 19)->nullable(); - $table->unsignedDecimal('gross_weight', 19)->nullable(); + $table->unsignedDecimal('cargo_capacity')->nullable(); + $table->unsignedDecimal('fuel_capacity')->nullable(); + $table->unsignedDecimal('gross_weight')->nullable(); $table->timestamps(); }); Schema::create('subfleet_expenses', function(Blueprint $table) { $table->unsignedBigInteger('subfleet_id'); $table->string('name', 50); - $table->unsignedDecimal('cost', 19); + $table->unsignedDecimal('cost'); $table->primary(['subfleet_id', 'name']); }); @@ -36,8 +36,8 @@ class CreateSubfleetTables extends Migration Schema::create('subfleet_fare', function (Blueprint $table) { $table->unsignedInteger('subfleet_id'); $table->unsignedInteger('fare_id'); - $table->unsignedDecimal('price', 19)->nullable(); - $table->unsignedDecimal('cost', 19)->nullable(); + $table->unsignedDecimal('price')->nullable(); + $table->unsignedDecimal('cost')->nullable(); $table->unsignedInteger('capacity')->nullable(); $table->timestamps(); @@ -56,8 +56,8 @@ class CreateSubfleetTables extends Migration Schema::create('subfleet_rank', function(Blueprint $table) { $table->unsignedInteger('rank_id'); $table->unsignedInteger('subfleet_id'); - $table->unsignedDecimal('acars_pay', 19)->nullable(); - $table->unsignedDecimal('manual_pay', 19)->nullable(); + $table->unsignedDecimal('acars_pay')->nullable(); + $table->unsignedDecimal('manual_pay')->nullable(); $table->primary(['rank_id', 'subfleet_id']); $table->index(['subfleet_id', 'rank_id']); 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 f293de0d..847ccd34 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 @@ -18,11 +18,11 @@ class CreatePirepTables extends Migration public function up() { Schema::create('pireps', function (Blueprint $table) { - $table->string('id', 12); + $table->string('id', \App\Models\Pirep::ID_MAX_LENGTH); $table->unsignedInteger('user_id'); $table->unsignedInteger('airline_id'); $table->unsignedInteger('aircraft_id')->nullable(); - $table->string('flight_id', 12)->nullable(); + $table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH)->nullable(); $table->string('flight_number', 10)->nullable(); $table->string('route_code', 5)->nullable(); $table->string('route_leg', 5)->nullable(); @@ -33,10 +33,10 @@ class CreatePirepTables extends Migration $table->unsignedDecimal('planned_distance')->nullable(); $table->unsignedInteger('flight_time')->nullable(); $table->unsignedInteger('planned_flight_time')->nullable(); - $table->unsignedDecimal('zfw', 19)->nullable(); - $table->unsignedDecimal('block_fuel', 19)->nullable(); - $table->unsignedDecimal('fuel_used', 19)->nullable(); - $table->decimal('landing_rate', 8)->nullable(); + $table->unsignedDecimal('zfw')->nullable(); + $table->unsignedDecimal('block_fuel')->nullable(); + $table->unsignedDecimal('fuel_used')->nullable(); + $table->decimal('landing_rate')->nullable(); $table->text('route')->nullable(); $table->text('notes')->nullable(); $table->unsignedTinyInteger('source')->nullable()->default(0); @@ -55,7 +55,7 @@ class CreatePirepTables extends Migration Schema::create('pirep_comments', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('pirep_id', 12); + $table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH); $table->unsignedInteger('user_id'); $table->text('comment'); $table->timestamps(); @@ -66,16 +66,16 @@ class CreatePirepTables extends Migration */ Schema::create('pirep_expenses', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('pirep_id', 12); + $table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH); $table->string('name'); - $table->double('value', 19, 2)->nullable(); + $table->double('value')->nullable(); $table->index('pirep_id'); }); Schema::create('pirep_fares', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('pirep_id', 12); + $table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH); $table->unsignedBigInteger('fare_id'); $table->unsignedInteger('count')->nullable(); @@ -94,7 +94,7 @@ class CreatePirepTables extends Migration Schema::create('pirep_field_values', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('pirep_id', 12); + $table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH); $table->string('name', 50); $table->string('value')->nullable(); $table->string('source')->nullable(); diff --git a/app/Database/migrations/2017_12_12_174519_create_bids_table.php b/app/Database/migrations/2017_12_12_174519_create_bids_table.php index 45853ac4..f9ad6d6d 100644 --- a/app/Database/migrations/2017_12_12_174519_create_bids_table.php +++ b/app/Database/migrations/2017_12_12_174519_create_bids_table.php @@ -16,7 +16,7 @@ class CreateBidsTable extends Migration Schema::create('user_bids', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('user_id'); - $table->string('flight_id', 12); + $table->string('flight_id', \App\Models\Flight::ID_MAX_LENGTH); $table->timestamps(); $table->index('user_id'); 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 238aa3ae..402a3af3 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 @@ -15,7 +15,7 @@ class CreateAcarsTables extends Migration { Schema::create('acars', function (Blueprint $table) { $table->string('id', 12); - $table->string('pirep_id', 12); + $table->string('pirep_id', \App\Models\Pirep::ID_MAX_LENGTH); $table->unsignedTinyInteger('type'); $table->unsignedInteger('nav_type')->nullable(); $table->unsignedInteger('order')->default(0); diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 3106f487..0443f6dd 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -13,6 +13,8 @@ class Flight extends BaseModel { use HashId; + public const ID_MAX_LENGTH = 12; + public $table = 'flights'; public $incrementing = false; diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 8c078a4b..60813070 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -8,7 +8,6 @@ use App\Models\Traits\HashId; use App\Support\Units\Distance; use App\Support\Units\Fuel; -use App\Support\Units\Time; use PhpUnitsOfMeasure\Exception\NonNumericValue; use PhpUnitsOfMeasure\Exception\NonStringUnitName; @@ -21,6 +20,8 @@ class Pirep extends BaseModel { use HashId; + public const ID_MAX_LENGTH = 12; + public $table = 'pireps'; public $incrementing = false;