<?php

namespace Database\Seeders;

use App\Models\Brand;
use App\Models\CarModel;
use App\Models\Trim;
use Illuminate\Database\Seeder;

class BrandSeeder extends Seeder
{
    public function run(): void
    {
        $data = [
            'Toyota' => [
                'Camry' => ['LE', 'SE', 'XLE', 'XSE'],
                'Corolla' => ['L', 'LE', 'SE', 'XSE'],
                'Land Cruiser' => ['GXR', 'VXR', 'GR Sport'],
            ],
            'Tesla' => [
                'Model 3' => ['Standard Range Plus', 'Long Range', 'Performance'],
                'Model S' => ['Long Range', 'Plaid'],
                'Model X' => ['Long Range', 'Plaid'],
            ],
            'Mercedes-Benz' => [
                'S-Class' => ['S450', 'S500', 'S580', 'Maybach'],
                'E-Class' => ['E200', 'E300', 'E350', 'E450'],
                'C-Class' => ['C200', 'C300', 'AMG C43', 'AMG C63'],
            ],
            'BMW' => [
                '7 Series' => ['740i', '750i', '760i', 'M760Li'],
                '5 Series' => ['520i', '530i', '540i', 'M5'],
                'M4' => ['Coupe', 'Competition', 'CSL'],
            ],
            'Audi' => [
                'A8' => ['55 TFSI', '60 TFSI', 'S8'],
                'RS7' => ['Sportback', 'Performance'],
                'Q8' => ['45 TFSI', '55 TFSI', 'RS Q8'],
            ],
        ];

        foreach ($data as $brandName => $models) {
            $brand = Brand::create(['name' => $brandName]);
            foreach ($models as $modelName => $trims) {
                $model = CarModel::create([
                    'brand_id' => $brand->id,
                    'name' => $modelName,
                ]);
                foreach ($trims as $trimName) {
                    Trim::create([
                        'car_model_id' => $model->id,
                        'name' => $trimName,
                    ]);
                }
            }
        }
    }
}
