<?php

namespace Database\Seeders;

use Faker\Factory as Faker;

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

use App\Models\Notice;
use App\Models\User;
use App\Models\Teacher;
use App\Models\Student;

class NoticeSeeder extends Seeder
{
  /**
   * Run the database seeds.
   */
  public function run(): void
  {
    $user_1 = User::find(1);
    $user_2 = User::find(2);
    $user_3 = User::find(3);

    $teacher_1 = Teacher::find(1);
    $teacher_2 = Teacher::find(2);
    $teacher_amy = Teacher::where(
      'email',
      '=',
      'amy_tsui@school.com'
    )->get()[0];

    $student_1 = Student::find(1);
    $student_2 = Student::find(2);
    $student_john = Student::where(
      'email',
      '=',
      'john_ho@school.com'
    )->get()[0];

    // NOTE: debug use
    Notice::factory()->create([
      'date' => '2023-04-01',
      'subject' => 'teacher_amy->student_john notice',
      'from' => $teacher_amy->email,
      'to' => $student_john->email,
      'status' => 'unread',
      'content' => 'teacher_amy->student_john content',
    ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "teacher_1->student_2 notice",
    //     'from'=> $teacher_1->email,
    //     'to' =>$student_2->email,
    //     'status' => 'unread',
    //     'content'=>"teacher_1->student_2 content"
    // ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "user_1->user_2 notice",
    //     'from'=> $user_1->email,
    //     'to' =>$user_2->email,
    //     'status' => 'unread',
    //     'content'=>"user1->user2 content"
    // ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "teacher_1->teacher_2 notice",
    //     'from'=> $teacher_1->email,
    //     'to' =>$teacher_2->email,
    //     'status' => 'unread',
    //     'content'=>"user1->user2 content"
    // ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "student_1->student_2 notice",
    //     'from'=> $student_1->email,
    //     'to' =>$student_2->email,
    //     'status' => 'unread',
    //     'content'=>"user1->user2 content"
    // ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "teacher_1->student_2 notice",
    //     'from'=> $teacher_1->email,
    //     'to' =>$student_2->email,
    //     'status' => 'unread',
    //     'content'=>"user1->user2 content"
    // ]);

    // Notice::factory()->create([
    //     'date' => '2023-04-01',
    //     'subject' => "student_2->teacher_1 notice",
    //     'from'=> $student_2->email,
    //     'to' =>$teacher_1->email,
    //     'status' => 'unread',
    //     'content'=>"user1->user2 content"
    // ]);

    // $faker = Faker::create();
    // foreach (range(2, 9) as $index) {
    //     Notice::factory()->create([
    //         'date' => '2023-04-' . $index,
    //         'subject' => 'notice subject '.$index,
    //         'from'=> $user_1->id,
    //         'to' =>$user_3->id,
    //         'content'=>"notice content" . $index
    //     ]);
    // }
  }
}
