<?php

namespace Database\Seeders;

use App\Models\Claim\Area;
use App\Models\Claim\Council;
use Illuminate\Database\Seeder;

/**
 * Seed Scotland councils + their areas from database/data/councils_areas.php
 * (generated from "Council & Suburbs.ods"). Idempotent — safe to re-run.
 */
class ScotlandAreasSeeder extends Seeder
{
    public function run(): void
    {
        $data = require database_path('data/councils_areas.php');

        foreach ($data as $councilName => $areas) {
            $council = Council::firstOrCreate(['name' => $councilName]);

            foreach ($areas as $areaName) {
                Area::firstOrCreate([
                    'council_id' => $council->id,
                    'name'       => $areaName,
                ]);
            }
        }
    }
}
