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 15ca3f24..b6c016e2 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 @@ -73,6 +73,15 @@ class CreateFlightTables extends Migration $table->index('flight_id'); }); + + Schema::create('flight_subfleet', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->unsignedInteger('subfleet_id'); + $table->string('flight_id', \App\Interfaces\Model::ID_MAX_LENGTH); + + $table->index(['subfleet_id', 'flight_id']); + $table->index(['flight_id', 'subfleet_id']); + }); } /** @@ -84,6 +93,7 @@ class CreateFlightTables extends Migration { Schema::drop('flight_fields'); Schema::drop('flight_fare'); + Schema::drop('flight_subfleet'); Schema::drop('flights'); } } 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 d33cbd59..86cfea54 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 @@ -35,14 +35,6 @@ class CreateSubfleetTables extends Migration $table->index(['fare_id', 'subfleet_id']); }); - Schema::create('subfleet_flight', function (Blueprint $table) { - $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->unsignedInteger('rank_id'); $table->unsignedInteger('subfleet_id'); @@ -63,7 +55,6 @@ class CreateSubfleetTables extends Migration { Schema::dropIfExists('subfleets'); Schema::dropIfExists('subfleet_fare'); - Schema::dropIfExists('subfleet_flight'); Schema::dropIfExists('subfleet_rank'); } } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index af83ec8e..acab071e 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -175,6 +175,6 @@ class Flight extends Model public function subfleets() { - return $this->belongsToMany(Subfleet::class, 'subfleet_flight'); + return $this->belongsToMany(Subfleet::class, 'flight_subfleet'); } } diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 729117ff..ab5edf3d 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -8,6 +8,7 @@ use App\Models\Traits\ExpensableTrait; /** * Class Subfleet + * @property int id * @property string type * @property string ground_handling_multiplier * @package App\Models @@ -81,7 +82,7 @@ class Subfleet extends Model public function flights() { - return $this->belongsToMany(Flight::class, 'subfleet_flight'); + return $this->belongsToMany(Flight::class, 'flight_subfleet'); } public function ranks()