<?php

namespace Database\Seeders;

use App\Enums\RegistrationStatus;
use App\Models\CourseRegistration;
use App\Models\CourseRegistrationSubmission;
use App\Models\CourseRegistrationSubmissionLog;
use Illuminate\Database\Seeder;

class CourseRegistrationSeeder extends Seeder
{
    public function run(): void
    {
        $approved = CourseRegistrationSubmission::create([
            'student_id' => 1,
            'academic_term_id' => 2,
            'status' => RegistrationStatus::Approved,
            'signed_at' => '2026-01-20 08:00:00',
            'reviewed_by' => 1,
            'reviewed_at' => '2026-01-20 13:00:00',
            'created_at' => '2026-01-20 08:00:00',
            'updated_at' => '2026-01-20 13:00:00',
        ]);

        CourseRegistration::create([
            'student_id' => 1,
            'academic_term_id' => 2,
            'course_class_id' => 1,
            'submission_id' => $approved->id,
            'created_at' => '2026-01-20 08:00:00',
            'updated_at' => '2026-01-20 08:00:00',
        ]);

        CourseRegistrationSubmissionLog::insert([
            [
                'submission_id' => $approved->id,
                'status' => RegistrationStatus::Submitted->value,
                'reason' => null,
                'actor_id' => 1,
                'created_at' => '2026-01-20 08:00:00',
                'updated_at' => '2026-01-20 08:00:00',
            ],
            [
                'submission_id' => $approved->id,
                'status' => RegistrationStatus::Approved->value,
                'reason' => null,
                'actor_id' => 1,
                'created_at' => '2026-01-20 13:00:00',
                'updated_at' => '2026-01-20 13:00:00',
            ],
        ]);

        $submitted = CourseRegistrationSubmission::create([
            'student_id' => 2,
            'academic_term_id' => 2,
            'status' => RegistrationStatus::Submitted,
            'signed_at' => '2026-01-20 08:10:00',
            'created_at' => '2026-01-20 08:10:00',
            'updated_at' => '2026-01-20 08:10:00',
        ]);

        CourseRegistration::create([
            'student_id' => 2,
            'academic_term_id' => 2,
            'course_class_id' => 2,
            'submission_id' => $submitted->id,
            'created_at' => '2026-01-20 08:10:00',
            'updated_at' => '2026-01-20 08:10:00',
        ]);

        CourseRegistrationSubmissionLog::create([
            'submission_id' => $submitted->id,
            'status' => RegistrationStatus::Submitted->value,
            'reason' => null,
            'actor_id' => 2,
            'created_at' => '2026-01-20 08:10:00',
            'updated_at' => '2026-01-20 08:10:00',
        ]);
    }
}
