<?php

namespace Database\Seeders;

use Faker\Factory as Faker;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

use App\Models\Exam;
use App\Models\Student;
use App\Models\Subject;
use App\Models\Teacher;

class ExamSeeder extends Seeder
{
  /**
   * Run the database seeds.
   */
  public function run(): void
  {
    $subject = Subject::find(1);

    $exam_1 = Exam::factory()->create([
      'date' => '2023-08-01',
      'subject_id' => $subject->id,
      'title' => $subject->subjectTitle . ' mid term examination',
      'remarks' => '',
    ]);

    $faker = Faker::create();
    foreach (range(2, 5) as $index) {
      $subject = Subject::find($index);

      Exam::factory()->create([
        'date' => '2023-04-' . $index,
        'subject_id' => $subject->id,
        'title' => $subject->subjectTitle . ' mid term',
        'remarks' => $subject->subjectTitle . ' mid term examination',
      ]);
    }

    $exam_1 = Exam::find(1);
    $exam_2 = Exam::find(2);

    $student_1 = Exam::find(1);
    $student_2 = Exam::find(2);
    $student_3 = Exam::find(3);

    // $exam_1->students()->attach($student_3);
    // $exam_1->students()->attach($student_1);

    // $exam_2->students()->attach($student_3);

    // // TODO: temp fix
    // $exam_2->students()->attach($student_1);
  }
}
