<?php

namespace Database\Seeders;

use App\Models\Project;
use Illuminate\Database\Seeder;

class ProjectComponentSeeder extends Seeder
{
    public function run(): void
    {
        $components = [
            'Block A1',
            'Block A2',
            'Block A3',
            'Block A4',
            'Block B1',
            'Block B2',
            'Block B3',
            'Kindergarten',
            'Administration block',
            'Classes',
            'Dinning hall',
            'Market block',
        ];

        Project::query()->each(function (Project $project) use ($components) {
            foreach ($components as $index => $name) {
                $project->components()->firstOrCreate(
                    ['name' => $name],
                    [
                        'sort_order' => $index,
                        'is_active' => true,
                    ]
                );
            }
        });
    }
}
