diff --git a/README.md b/README.md index 52e1c2a..5390760 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,21 @@ # Relations -## AircraftManufacturers +## AircraftManufacturer - HasMany AircraftType -## AircraftTypes +## AircraftType -- BelongsTo AircraftManufacturers -- **TODO** BelongsTo Typeratings (External DB) -- HasMany Aircrafts +- BelongsTo AircraftManufacturer +- BelongsTo Typerating (External DB, creation in Schooling Plugin) +- HasMany Aircraft -## Aircrafts +## Aircraft -- BelongsTo AircraftTypes -- BelongsToMany AircraftTypeGroups -- **TODO** BelongsTo Airports (External DB, Multiple) +- BelongsTo AircraftType +- BelongsToMany AircraftTypeGroup +- **TODO** BelongsTo Airport (External DB) -## AircraftTypeGroups +## AircraftTypeGroup -- BelongsToMany AircraftTypes - ---- +- BelongsToMany AircraftType diff --git a/models/AircraftType.php b/models/AircraftType.php index 198ae3e..2075987 100644 --- a/models/AircraftType.php +++ b/models/AircraftType.php @@ -25,7 +25,7 @@ class AircraftType extends Model * @var array Validation rules */ public $rules = [ - 'aircraft_manufacturer' => 'required', + 'aircraft_manufacturer_id' => 'required', 'typerating_id' => 'required', 'only_charter' => 'required', 'type' => 'required', @@ -52,6 +52,7 @@ class AircraftType extends Model public $belongsTo = [ 'aircraft_manufacturer' => 'GermanAirlinesVa\Fleet\Models\AircraftManufacturer', + 'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating', ]; public $belongsToMany = [ diff --git a/models/aircrafttype/columns.yaml b/models/aircrafttype/columns.yaml index b3451b5..2e14455 100644 --- a/models/aircrafttype/columns.yaml +++ b/models/aircrafttype/columns.yaml @@ -2,12 +2,16 @@ columns: id: label: id type: text - aircraft_manufacturers_id: - label: aircraft_manufacturers_id - type: number - typerating_id: - label: typerating_id - type: number + aircraft_manufacturer: + label: aircraft_manufacturer + relation: aircraft_manufacturer + type: text + valueFrom: name + typerating: + label: typerating + relation: typerating + type: text + valueFrom: name only_charter: label: only_charter type: text diff --git a/models/aircrafttype/fields.yaml b/models/aircrafttype/fields.yaml index 481a11d..9adeab4 100644 --- a/models/aircrafttype/fields.yaml +++ b/models/aircrafttype/fields.yaml @@ -8,11 +8,13 @@ tabs: required: 1 type: relation tab: 'germanairlinesva.fleet::lang.aircraft_types.tabs.operational' - typerating_id: + typerating: label: 'germanairlinesva.fleet::lang.aircraft_types.typerating_id' + nameFrom: name + descriptionFrom: description span: auto required: 1 - type: number + type: relation tab: 'germanairlinesva.fleet::lang.aircraft_types.tabs.operational' only_charter: label: 'germanairlinesva.fleet::lang.aircraft_types.only_charter' diff --git a/updates/builder_table_create_aircraft_manufacturers.php b/updates/builder_table_create_aircraft_manufacturers.php index e3c4c35..1149d81 100644 --- a/updates/builder_table_create_aircraft_manufacturers.php +++ b/updates/builder_table_create_aircraft_manufacturers.php @@ -19,6 +19,8 @@ class BuilderTableCreateGermanAirlinesVaAircraftManufacturers extends Migration public function down() { + Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints(); Schema::connection('germanairlinesva_fleet')->dropIfExists('aircraft_manufacturers'); + Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints(); } } diff --git a/updates/builder_table_create_aircraft_types.php b/updates/builder_table_create_aircraft_types.php index 735ba38..59b3e7c 100644 --- a/updates/builder_table_create_aircraft_types.php +++ b/updates/builder_table_create_aircraft_types.php @@ -17,10 +17,6 @@ class BuilderTableCreateGermanAirlinesVaAircraftTypes extends Migration ->references('id') ->on('aircraft_manufacturers'); $table->bigInteger('typerating_id')->unsigned(); - //$table - // ->foreign('typerating_id') - // ->references('id') - // ->on('typeratings'); $table->boolean('only_charter'); $table->string('type'); $table->text('description');