diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 318c0a1c..98df46fa 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -28,15 +28,9 @@ class Subfleet extends Model protected $casts = [ 'airline_id' => 'integer', 'fuel_type' => 'integer', - ]; - - /** - * Validation rules - * - * @var array - */ - public static $rules = [ - + 'cargo_capacity' => 'double', + 'fuel_capacity' => 'double', + 'gross_weight' => 'double', ]; public function airline() diff --git a/app/Models/Traits/HashId.php b/app/Models/Traits/HashId.php index c3c100f5..f9d791dc 100644 --- a/app/Models/Traits/HashId.php +++ b/app/Models/Traits/HashId.php @@ -16,7 +16,7 @@ trait HashId $key = $model->getKeyName(); if (empty($model->{$key})) { - $hashids = new Hashids('', 10); + $hashids = new Hashids('', 12); $mt = str_replace('.', '', microtime(true)); $id = $hashids->encode($mt); diff --git a/database/migrations/2017_06_08_0000_create_users_table.php b/database/migrations/2017_06_08_0000_create_users_table.php index 27fa840d..4c37398d 100755 --- a/database/migrations/2017_06_08_0000_create_users_table.php +++ b/database/migrations/2017_06_08_0000_create_users_table.php @@ -19,14 +19,14 @@ class CreateUsersTable extends Migration $table->string('email')->unique(); $table->string('password'); $table->string('apikey', 40)->nullable(); - $table->integer('airline_id')->nullable()->unsigned(); - $table->integer('rank_id')->nullable()->unsigned(); + $table->unsignedInteger('airline_id')->unsigned(); + $table->unsignedInteger('rank_id')->unsigned(); $table->string('home_airport_id', 5)->nullable(); $table->string('curr_airport_id', 5)->nullable(); - $table->string('last_pirep_id')->nullable(); - $table->bigInteger('flights')->unsigned()->default(0); - $table->bigInteger('flight_time')->unsigned()->default(0); - $table->decimal('balance', 19, 2)->nullable(); + $table->string('last_pirep_id', 12)->nullable(); + $table->unsignedBigInteger('flights')->default(0); + $table->unsignedBigInteger('flight_time')->default(0); + $table->decimal('balance', 19)->nullable(); $table->string('timezone', 64)->nullable(); $table->boolean('active')->nullable(); $table->rememberToken(); @@ -48,8 +48,8 @@ class CreateUsersTable extends Migration // Create table for associating roles to users (Many-to-Many) Schema::create('role_user', function (Blueprint $table) { - $table->integer('user_id')->unsigned(); - $table->integer('role_id')->unsigned(); + $table->unsignedInteger('user_id'); + $table->unsignedInteger('role_id'); $table->foreign('user_id')->references('id')->on('users') ->onUpdate('cascade')->onDelete('cascade'); @@ -71,8 +71,8 @@ class CreateUsersTable extends Migration // Create table for associating permissions to roles (Many-to-Many) Schema::create('permission_role', function (Blueprint $table) { - $table->integer('permission_id')->unsigned(); - $table->integer('role_id')->unsigned(); + $table->unsignedInteger('permission_id'); + $table->unsignedInteger('role_id'); $table->foreign('permission_id')->references('id')->on('permissions') ->onUpdate('cascade')->onDelete('cascade'); diff --git a/database/migrations/2017_06_08_191703_create_airlines_table.php b/database/migrations/2017_06_08_191703_create_airlines_table.php index a5fce623..eef156ee 100644 --- a/database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/database/migrations/2017_06_08_191703_create_airlines_table.php @@ -16,7 +16,7 @@ class CreateAirlinesTable extends Migration Schema::create('airlines', function (Blueprint $table) { $table->increments('id'); $table->string('icao', 5); - $table->string('iata', 3)->nullable(); + $table->string('iata', 5)->nullable(); $table->string('name', 50); $table->string('country', 2)->nullable(); $table->string('logo', 255)->nullable(); diff --git a/database/migrations/2017_06_09_010621_create_aircrafts_table.php b/database/migrations/2017_06_09_010621_create_aircrafts_table.php index d4804bee..6c63bd39 100644 --- a/database/migrations/2017_06_09_010621_create_aircrafts_table.php +++ b/database/migrations/2017_06_09_010621_create_aircrafts_table.php @@ -9,7 +9,7 @@ class CreateAircraftsTable extends Migration { Schema::create('aircraft', function (Blueprint $table) { $table->increments('id'); - $table->integer('subfleet_id')->unsigned(); + $table->unsignedInteger('subfleet_id'); $table->string('airport_id', 5)->nullable(); $table->string('hex_code', 10)->nullable(); $table->string('name', 50); diff --git a/database/migrations/2017_06_10_040335_create_fares_table.php b/database/migrations/2017_06_10_040335_create_fares_table.php index 2a31a0be..f812096d 100644 --- a/database/migrations/2017_06_10_040335_create_fares_table.php +++ b/database/migrations/2017_06_10_040335_create_fares_table.php @@ -14,12 +14,12 @@ class CreateFaresTable extends Migration public function up() { Schema::create('fares', function (Blueprint $table) { - $table->bigIncrements('id'); + $table->increments('id'); $table->string('code', 50); $table->string('name', 50); - $table->decimal('price', 19, 2)->default(0.0); - $table->decimal('cost', 19, 2)->default(0.0); - $table->integer('capacity')->default(0)->unsigned(); + $table->unsignedDecimal('price', 19)->default(0.00); + $table->unsignedDecimal('cost', 19)->default(0.00); + $table->unsignedInteger('capacity')->default(0); $table->string('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); diff --git a/database/migrations/2017_06_11_135707_create_airports_table.php b/database/migrations/2017_06_11_135707_create_airports_table.php index 6b8e0cae..f1a45d14 100644 --- a/database/migrations/2017_06_11_135707_create_airports_table.php +++ b/database/migrations/2017_06_11_135707_create_airports_table.php @@ -15,9 +15,9 @@ class CreateAirportsTable extends Migration $table->string('location', 100)->nullable(); $table->string('country', 48)->nullable(); $table->string('tz', 64)->nullable(); - $table->double('fuel_100ll_cost', 19, 2)->default(0); - $table->double('fuel_jeta_cost', 19, 2)->default(0); - $table->double('fuel_mogas_cost', 19, 2)->default(0); + $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(); }); diff --git a/database/migrations/2017_06_17_214650_create_flight_tables.php b/database/migrations/2017_06_17_214650_create_flight_tables.php index 7fd97f70..5f050246 100644 --- a/database/migrations/2017_06_17_214650_create_flight_tables.php +++ b/database/migrations/2017_06_17_214650_create_flight_tables.php @@ -14,8 +14,8 @@ class CreateFlightTables extends Migration public function up() { Schema::create('flights', function (Blueprint $table) { - $table->uuid('id'); - $table->integer('airline_id')->unsigned(); + $table->string('id', 12); + $table->unsignedInteger('airline_id'); $table->string('flight_number', 10); $table->string('route_code', 5)->nullable(); $table->string('route_leg', 5)->nullable(); @@ -23,9 +23,9 @@ class CreateFlightTables extends Migration $table->string('arr_airport_id', 5); $table->string('alt_airport_id', 5)->nullable(); $table->text('route')->nullable(); - $table->text('dpt_time', 10)->nullable(); - $table->text('arr_time', 10)->nullable(); - $table->double('flight_time', 19, 2)->unsigned()->nullable(); + $table->string('dpt_time', 10)->nullable(); + $table->string('arr_time', 10)->nullable(); + $table->unsignedDecimal('flight_time', 19)->nullable(); $table->text('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); @@ -40,13 +40,14 @@ class CreateFlightTables extends Migration }); Schema::create('flight_fields', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->uuid('flight_id'); + $table->increments('id'); + $table->string('flight_id', 12); $table->string('name', 50); $table->text('value'); $table->timestamps(); - }); + $table->index('flight_id'); + }); } /** diff --git a/database/migrations/2017_06_21_165410_create_ranks_table.php b/database/migrations/2017_06_21_165410_create_ranks_table.php index 4e89b8fb..75f9e682 100644 --- a/database/migrations/2017_06_21_165410_create_ranks_table.php +++ b/database/migrations/2017_06_21_165410_create_ranks_table.php @@ -16,7 +16,7 @@ class CreateRanksTable extends Migration Schema::create('ranks', function (Blueprint $table) { $table->increments('id'); $table->string('name', 50); - $table->integer('hours')->default(0); + $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); diff --git a/database/migrations/2017_06_23_011011_create_subfleet_tables.php b/database/migrations/2017_06_23_011011_create_subfleet_tables.php index 04198f96..7a0e2ef4 100644 --- a/database/migrations/2017_06_23_011011_create_subfleet_tables.php +++ b/database/migrations/2017_06_23_011011_create_subfleet_tables.php @@ -14,31 +14,31 @@ class CreateSubfleetTables extends Migration public function up() { Schema::create('subfleets', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->integer('airline_id')->unsigned()->nullable(); + $table->increments('id'); + $table->unsignedInteger('airline_id')->nullable(); $table->string('name', 50); $table->string('type', 7); - $table->tinyInteger('fuel_type')->unsigned()->nullable(); - $table->double('cargo_capacity', 19, 2)->nullable(); - $table->double('fuel_capacity', 19, 2)->nullable(); - $table->double('gross_weight', 19, 2)->nullable(); + $table->unsignedTinyInteger('fuel_type')->nullable(); + $table->unsignedDecimal('cargo_capacity', 19)->nullable(); + $table->unsignedDecimal('fuel_capacity', 19)->nullable(); + $table->unsignedDecimal('gross_weight', 19)->nullable(); $table->timestamps(); }); Schema::create('subfleet_expenses', function(Blueprint $table) { - $table->integer('subfleet_id')->unsigned(); + $table->unsignedBigInteger('subfleet_id'); $table->string('name', 50); - $table->decimal('cost', 19, 2)->unsigned(); + $table->unsignedDecimal('cost', 19); $table->primary(['subfleet_id', 'name']); }); Schema::create('subfleet_fare', function (Blueprint $table) { - $table->integer('subfleet_id')->unsigned(); - $table->integer('fare_id')->unsigned(); - $table->decimal('price', 19, 2)->nullable(); - $table->decimal('cost', 19, 2)->nullable(); - $table->integer('capacity')->nullable()->unsigned(); + $table->unsignedInteger('subfleet_id'); + $table->unsignedInteger('fare_id'); + $table->unsignedDecimal('price', 19)->nullable(); + $table->unsignedDecimal('cost', 19)->nullable(); + $table->unsignedInteger('capacity')->nullable(); $table->timestamps(); $table->primary(['subfleet_id', 'fare_id']); @@ -46,18 +46,18 @@ class CreateSubfleetTables extends Migration }); Schema::create('subfleet_flight', function(Blueprint $table) { - $table->integer('subfleet_id')->unsigned(); - $table->uuid('flight_id'); + $table->unsignedInteger('subfleet_id'); + $table->string('flight_id', 12); $table->primary(['subfleet_id', 'flight_id']); $table->index(['flight_id', 'subfleet_id']); }); Schema::create('subfleet_rank', function(Blueprint $table) { - $table->integer('rank_id')->unsigned(); - $table->integer('subfleet_id')->unsigned(); - $table->double('acars_pay', 19, 2)->unsigned()->nullable(); - $table->double('manual_pay', 19, 2)->unsigned()->nullable(); + $table->unsignedInteger('rank_id'); + $table->unsignedInteger('subfleet_id'); + $table->unsignedDecimal('acars_pay', 19)->nullable(); + $table->unsignedDecimal('manual_pay', 19)->nullable(); $table->primary(['rank_id', 'subfleet_id']); $table->index(['subfleet_id', 'rank_id']); diff --git a/database/migrations/2017_06_28_195426_create_pirep_tables.php b/database/migrations/2017_06_28_195426_create_pirep_tables.php index 36a714ca..75ee5f6b 100644 --- a/database/migrations/2017_06_28_195426_create_pirep_tables.php +++ b/database/migrations/2017_06_28_195426_create_pirep_tables.php @@ -14,23 +14,23 @@ class CreatePirepTables extends Migration public function up() { Schema::create('pireps', function (Blueprint $table) { - $table->uuid('id'); - $table->integer('user_id')->unsigned(); - $table->integer('airline_id')->unsigned(); - $table->integer('aircraft_id')->nullable(); + $table->string('id', 12); + $table->unsignedInteger('user_id'); + $table->unsignedInteger('airline_id'); + $table->unsignedInteger('aircraft_id')->nullable(); $table->uuid('flight_id')->nullable(); $table->string('flight_number', 10)->nullable(); $table->string('route_code', 5)->nullable(); $table->string('route_leg', 5)->nullable(); $table->string('dpt_airport_id', 5); $table->string('arr_airport_id', 5); - $table->double('flight_time', 19, 2)->unsigned(); - $table->double('gross_weight', 19, 2)->nullable(); - $table->double('fuel_used', 19, 2)->nullable(); + $table->unsignedDecimal('flight_time', 19); + $table->unsignedDecimal('gross_weight', 19)->nullable(); + $table->unsignedDecimal('fuel_used', 19)->nullable(); $table->string('route')->nullable(); $table->string('notes')->nullable(); - $table->tinyInteger('source')->default(0); - $table->tinyInteger('status')->default(0); + $table->unsignedTinyInteger('source')->default(0); + $table->unsignedTinyInteger('status')->default(0); $table->longText('raw_data')->nullable(); $table->timestamps(); $table->softDeletes(); @@ -44,16 +44,16 @@ class CreatePirepTables extends Migration Schema::create('pirep_comments', function (Blueprint $table) { $table->bigIncrements('id'); - $table->uuid('pirep_id'); - $table->bigInteger('user_id', false, true); + $table->string('pirep_id', 12); + $table->unsignedInteger('user_id'); $table->text('comment'); $table->timestamps(); }); Schema::create('pirep_events', function(Blueprint $table) { - $table->bigIncrements('id')->unsigned(); - $table->uuid('pirep_id'); - $table->string('event'); + $table->bigIncrements('id'); + $table->string('pirep_id', 12); + $table->string('event', 64); $table->dateTime('dt'); }); @@ -62,7 +62,7 @@ class CreatePirepTables extends Migration */ Schema::create('pirep_expenses', function (Blueprint $table) { $table->bigIncrements('id'); - $table->uuid('pirep_id'); + $table->string('pirep_id', 12); $table->string('name'); $table->double('value', 19, 2)->nullable(); @@ -71,9 +71,9 @@ class CreatePirepTables extends Migration Schema::create('pirep_fares', function (Blueprint $table) { $table->bigIncrements('id'); - $table->uuid('pirep_id'); + $table->string('pirep_id', 12); $table->unsignedBigInteger('fare_id'); - $table->double('count', 19, 2)->nullable(); + $table->unsignedInteger('count')->nullable(); $table->index('pirep_id'); }); @@ -84,15 +84,15 @@ class CreatePirepTables extends Migration Schema::create('pirep_fields', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name', 50); - $table->integer('required'); + $table->boolean('required')->default(false); $table->timestamps(); }); Schema::create('pirep_field_values', function (Blueprint $table) { $table->bigIncrements('id'); - $table->uuid('pirep_id'); + $table->string('pirep_id', 12); $table->string('name', 50); - $table->text('value'); + $table->string('value')->nullable(); $table->string('source')->nullable(); $table->timestamps(); diff --git a/database/migrations/2017_12_10_014930_create_settings_table.php b/database/migrations/2017_12_10_014930_create_settings_table.php index 181fe11a..a174683a 100644 --- a/database/migrations/2017_12_10_014930_create_settings_table.php +++ b/database/migrations/2017_12_10_014930_create_settings_table.php @@ -14,14 +14,14 @@ class CreateSettingsTable extends Migration { Schema::create('settings', function (Blueprint $table) { $table->increments('id'); - $table->integer('order')->default(1); + $table->unsignedInteger('order')->default(1); $table->string('name'); $table->string('key'); $table->string('value'); $table->string('group')->nullable(); - $table->text('type')->nullable(); - $table->text('options')->nullable(); - $table->text('description')->nullable(); + $table->string('type')->nullable(); + $table->string('options')->nullable(); + $table->string('description')->nullable(); $table->timestamps(); $table->unique('key'); }); diff --git a/database/migrations/2017_12_12_174519_create_bids_table.php b/database/migrations/2017_12_12_174519_create_bids_table.php index 7456bd86..45853ac4 100644 --- a/database/migrations/2017_12_12_174519_create_bids_table.php +++ b/database/migrations/2017_12_12_174519_create_bids_table.php @@ -15,8 +15,8 @@ class CreateBidsTable extends Migration { Schema::create('user_bids', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id', false, true); - $table->uuid('flight_id'); + $table->unsignedInteger('user_id'); + $table->string('flight_id', 12); $table->timestamps(); $table->index('user_id');