<?php

use App\Models\Airline;
use App\Models\Country;
use App\Models\UserFlight;
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' => 'Pacific Blue',
            'internal_name' => 'pacific-blue',
            'IATA_code' => 'DJ',
            'ICAO_code' => 'PBN',
            'active' => false,
            'logo' => 'pacific-blue.png',
            'country_id' => Country::where('code', 'NZ')->first()->id,
        ]);

        $flightIds = [326, 327];

        UserFlight::whereIn('id', $flightIds)->update(['airline_id' => Airline::where('internal_name', 'pacific-blue')->first()->id]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        //
    }
};
