51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Models\Aircraft;
|
|
use App\Models\Airline;
|
|
use App\Models\Country;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Airline::create([
|
|
'name' => 'Scoot',
|
|
'IATA_code' => 'TR',
|
|
'ICAO_code' => 'TGW',
|
|
'internal_name' => 'scoot-new',
|
|
'logo' => 'TR.png',
|
|
'active' => true,
|
|
'country_id' => Country::whereCode('SG')->first()->id,
|
|
]);
|
|
|
|
Aircraft::where('manufacturer_code', 'ATR')
|
|
->each(function ($aircraft) {
|
|
$aircraft->update([
|
|
'model_full_name' => str_replace('ATR-', '', $aircraft->model_full_name),
|
|
]);
|
|
});
|
|
|
|
Aircraft::where('manufacturer_code', 'AIRBUS')
|
|
->each(function ($aircraft) {
|
|
$aircraft->update([
|
|
'model_full_name' => str_replace('A-', 'A', $aircraft->model_full_name),
|
|
]);
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
//
|
|
}
|
|
};
|