<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class CourseSeeder extends Seeder
{
    public function run(): void
    {
        $now = now();

        $courses = [
            // Level 1 S1
            ['PC1100', 'Hospitality Accounting',             1, 1],
            ['PC1101', 'Business Communication',             1, 1],
            ['PC1102', 'Introduction to Hospitality',        1, 1],
            ['PC1103', 'Food Safety 1A',                     1, 1],
            ['PC1104', 'Food Preparation Theory 1A',         1, 1],
            ['PC1105', 'Pastry Theory 1A',                   1, 1],
            ['PC1106', 'Pastry Practical 1A',                1, 1],
            ['PC1107', 'Food Preparation Practical 1A',      1, 1],

            // Level 1 S2
            ['PC1108', 'Food Preparation Practical 1B',      1, 2],
            ['PC1109', 'Pastry Theory 1B',                   1, 2],
            ['PC1110', 'Food Safety 1B',                     1, 2],
            ['PC1111', 'Food Preparation Practical 1B',      1, 2],
            ['PC1112', 'Pastry Practical 1B',                1, 2],
            ['PC1213', 'Work Related Learning',              1, 2],

            // Level 2 S1
            ['PC1200', 'Hospitality Management 11A',         2, 1],
            ['PC1201', 'Business Management',                2, 1],
            ['PC1202', 'Marketing Management',               2, 1],
            ['PC1203', 'Food Preparation Theory 11A',        2, 1],
            ['PC1204', 'Pastry Theory 11A',                  2, 1],
            ['PC1205', 'Food Preparation Practical 11A',     2, 1],
            ['PC1206', 'Pastry Practical 11A',               2, 1],

            // Level 2 S2
            ['PC1207', 'Hospitality Management 11B',         2, 2],
            ['PC1208', 'Digital Marketing',                  2, 2],
            ['PC1209', 'Entrepreneurship',                   2, 2],
            ['PC1210', 'Food Preparation Theory 11B',        2, 2],
            ['PC1211', 'Pastry Theory 11B',                  2, 2],
            ['PC1212', 'Food Preparation Practical 11B',     2, 2],
            ['PC1214', 'Pastry Practical 11B',               2, 2],   // renamed to avoid duplicate code
        ];

        foreach ($courses as [$code, $desc, $level, $sem]) {
            DB::table('courses')->updateOrInsert(
                ['course_code' => $code],
                [
                    'course_description' => $desc,
                    'level'              => $level,
                    'semester'           => $sem,
                    'credits'            => 12,
                    'created_at'         => $now,
                    'updated_at'         => $now,
                ]
            );
        }
    }
}
