<?php

namespace Database\Seeders;

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

class ChapterSeeder extends Seeder
{
    public function run(): void
    {
        $chapters = [
            // Year 1 (lesson_section_id = 1)
            ['lesson_section_id' => 1, 'title' => 'Algebra',              'order' => 1],
            ['lesson_section_id' => 1, 'title' => 'Quadratics',           'order' => 2],
            ['lesson_section_id' => 1, 'title' => 'Functions',            'order' => 3],
            ['lesson_section_id' => 1, 'title' => 'Graphs',               'order' => 4],
            ['lesson_section_id' => 1, 'title' => 'Linear Graphs',        'order' => 5],
            ['lesson_section_id' => 1, 'title' => 'Coordinate Geometry',  'order' => 6],
            ['lesson_section_id' => 1, 'title' => 'Circles',              'order' => 7],
            ['lesson_section_id' => 1, 'title' => 'Binomial Expansion',   'order' => 8],
            ['lesson_section_id' => 1, 'title' => 'Differentiation',      'order' => 9],
            ['lesson_section_id' => 1, 'title' => 'Integration',          'order' => 10],
            ['lesson_section_id' => 1, 'title' => 'Exponentials & Logs',  'order' => 11],
            ['lesson_section_id' => 1, 'title' => 'Trigonometry',         'order' => 12],
            ['lesson_section_id' => 1, 'title' => 'Trigonometric Graphs', 'order' => 13],
            ['lesson_section_id' => 1, 'title' => 'Trigonometric Identities & Equations', 'order' => 14],

            // Year 2 (lesson_section_id = 2)
            ['lesson_section_id' => 2, 'title' => 'Algebra',              'order' => 1],
            ['lesson_section_id' => 2, 'title' => 'Functions',            'order' => 2],
            ['lesson_section_id' => 2, 'title' => 'Graphs',               'order' => 3],
            ['lesson_section_id' => 2, 'title' => 'Sequences & Series',   'order' => 4],
            ['lesson_section_id' => 2, 'title' => 'Binomial Expansion',   'order' => 5],
            ['lesson_section_id' => 2, 'title' => 'Radian Measure',       'order' => 6],
            ['lesson_section_id' => 2, 'title' => 'Trigonometry',         'order' => 7],
            ['lesson_section_id' => 2, 'title' => 'Parametric Equations', 'order' => 8],
            ['lesson_section_id' => 2, 'title' => 'Differentiation',      'order' => 9],
            ['lesson_section_id' => 2, 'title' => 'Integration',          'order' => 10],
            ['lesson_section_id' => 2, 'title' => 'Numerical Methods',    'order' => 11],
            ['lesson_section_id' => 2, 'title' => 'Vectors',              'order' => 12],
        ];

        foreach ($chapters as $chapter) {
            Chapter::updateOrCreate(
                [
                    'lesson_section_id' => $chapter['lesson_section_id'],
                    'title'             => $chapter['title'],
                ],
                [
                    'order'             => $chapter['order'],
                ]
            );
        }
    }
}