<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Division;
use App\Models\District;

class DistrictSeeder extends Seeder
{
    public function run(): void
    {
        $data = [
            'Dhaka' => [
                ['ঢাকা', 'Dhaka'],
                ['গাজীপুর', 'Gazipur'],
                ['নারায়ণগঞ্জ', 'Narayanganj'],
                ['নরসিংদী', 'Narsingdi'],
                ['মানিকগঞ্জ', 'Manikganj'],
                ['মুন্সিগঞ্জ', 'Munshiganj'],
                ['টাঙ্গাইল', 'Tangail'],
                ['ফরিদপুর', 'Faridpur'],
                ['গোপালগঞ্জ', 'Gopalganj'],
                ['মাদারীপুর', 'Madaripur'],
                ['রাজবাড়ী', 'Rajbari'],
                ['শরীয়তপুর', 'Shariatpur'],
                ['কিশোরগঞ্জ', 'Kishoreganj'],
            ],

            'Chattogram' => [
                ['কুমিল্লা', 'Cumilla'],
                ['ফেনী', 'Feni'],
                ['ব্রাহ্মণবাড়িয়া', 'Brahmanbaria'],
                ['চাঁদপুর', 'Chandpur'],
                ['নোয়াখালী', 'Noakhali'],
                ['লক্ষ্মীপুর', 'Lakshmipur'],
                ['চট্টগ্রাম', 'Chattogram'],
                ['কক্সবাজার', 'Coxsbazar'],
                ['খাগড়াছড়ি', 'Khagrachari'],
                ['রাঙ্গামাটি', 'Rangamati'],
                ['বান্দরবান', 'Bandarban'],
            ],

            'Rajshahi' => [
                ['রাজশাহী', 'Rajshahi'],
                ['নাটোর', 'Natore'],
                ['নওগাঁ', 'Naogaon'],
                ['চাঁপাইনবাবগঞ্জ', 'Chapainawabganj'],
                ['পাবনা', 'Pabna'],
                ['সিরাজগঞ্জ', 'Sirajganj'],
                ['বগুড়া', 'Bogura'],
                ['জয়পুরহাট', 'Joypurhat'],
            ],

            'Khulna' => [
                ['খুলনা', 'Khulna'],
                ['যশোর', 'Jashore'],
                ['ঝিনাইদহ', 'Jhenaidah'],
                ['চুয়াডাঙ্গা', 'Chuadanga'],
                ['মেহেরপুর', 'Meherpur'],
                ['সাতক্ষীরা', 'Satkhira'],
                ['বাগেরহাট', 'Bagerhat'],
                ['নড়াইল', 'Narail'],
                ['মাগুরা', 'Magura'],
            ],

            'Barishal' => [
                ['বরিশাল', 'Barishal'],
                ['ঝালকাঠি', 'Jhalokathi'],
                ['পটুয়াখালী', 'Patuakhali'],
                ['পিরোজপুর', 'Pirojpur'],
                ['ভোলা', 'Bhola'],
                ['বরগুনা', 'Barguna'],
            ],

            'Sylhet' => [
                ['সিলেট', 'Sylhet'],
                ['মৌলভীবাজার', 'Moulvibazar'],
                ['হবিগঞ্জ', 'Habiganj'],
                ['সুনামগঞ্জ', 'Sunamganj'],
            ],

            'Rangpur' => [
                ['রংপুর', 'Rangpur'],
                ['দিনাজপুর', 'Dinajpur'],
                ['কুড়িগ্রাম', 'Kurigram'],
                ['গাইবান্ধা', 'Gaibandha'],
                ['লালমনিরহাট', 'Lalmonirhat'],
                ['নীলফামারী', 'Nilphamari'],
                ['পঞ্চগড়', 'Panchagarh'],
                ['ঠাকুরগাঁও', 'Thakurgaon'],
            ],

            'Mymensingh' => [
                ['ময়মনসিংহ', 'Mymensingh'],
                ['জামালপুর', 'Jamalpur'],
                ['শেরপুর', 'Sherpur'],
                ['নেত্রকোনা', 'Netrokona'],
            ],
        ];

        foreach ($data as $divisionEn => $districts) {
            $division = Division::where('name_en', $divisionEn)->first();

            if (!$division) continue;

            foreach ($districts as [$bn, $en]) {
                District::updateOrCreate(
                    [
                        'division_id' => $division->id,
                        'name_en' => $en,
                    ],
                    [
                        'name_bn' => $bn,
                    ]
                );
            }
        }
    }
}
