Files
FlightsAPI/database/migrations/2026_05_18_113037_extra_additions.php
T
2026-05-18 22:06:04 +10:00

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
{
//
}
};