first(); if (!$admin) return; $n5 = Level::where('code', 'N5')->first(); $basic = Level::where('code', 'BASIC')->first(); $n4 = Level::where('code', 'N4')->first(); // 1. Course: Mastering JLPT N5 $course1 = Course::updateOrCreate( ['slug' => 'mastering-jlpt-n5'], [ 'title' => 'Mastering JLPT N5: Dasar Bahasa Jepang', 'description' => 'Kursus lengkap untuk persiapan JLPT N5 dari nol.', 'level_id' => $n5->id, 'teacher_id' => $admin->id, 'is_published' => true, 'price' => 0, ] ); $module1 = Module::updateOrCreate( ['course_id' => $course1->id, 'title' => 'Introduction to N5'], ['order_index' => 1] ); $lessons1 = [ ['title' => 'Selamat Datang di N5', 'slug' => 'welcome-n5', 'type' => 'video', 'video_url' => 'https://www.youtube.com/watch?v=e8mQAY6HQQc'], ['title' => 'Struktur Menulis Jepang', 'slug' => 'writing-structure', 'type' => 'text', 'video_url' => null], ['title' => 'Kata Ganti Orang', 'slug' => 'pronouns', 'type' => 'video', 'video_url' => 'https://www.youtube.com/watch?v=e8mQAY6HQQc'], ]; foreach ($lessons1 as $index => $lessonData) { Lesson::updateOrCreate( ['module_id' => $module1->id, 'slug' => $lessonData['slug']], [ 'title' => $lessonData['title'], 'type' => $lessonData['type'], 'video_url' => $lessonData['video_url'], 'order_index' => $index + 1 ] ); } // 2. Course: Hiragana & Katakana $course2 = Course::updateOrCreate( ['slug' => 'kana-mastery'], [ 'title' => 'Katakana & Hiragana Mastery', 'description' => 'Kuasai cara baca dan tulis Hiragana & Katakana dalam 2 minggu.', 'level_id' => $basic->id, 'teacher_id' => $admin->id, 'is_published' => true, 'price' => 0, ] ); $module2 = Module::updateOrCreate( ['course_id' => $course2->id, 'title' => 'Hiragana Basics'], ['order_index' => 1] ); $lessons2 = [ ['title' => 'Baris A-I-U-E-O', 'slug' => 'vowels-kana', 'type' => 'video', 'video_url' => 'https://www.youtube.com/watch?v=icK6kVTegDA'], ['title' => 'Baris KA-KI-KU-KE-KO', 'slug' => 'ka-line', 'type' => 'video', 'video_url' => 'https://www.youtube.com/watch?v=icK6kVTegDA'], ]; foreach ($lessons2 as $index => $lessonData) { Lesson::updateOrCreate( ['module_id' => $module2->id, 'slug' => $lessonData['slug']], [ 'title' => $lessonData['title'], 'type' => $lessonData['type'], 'video_url' => $lessonData['video_url'], 'order_index' => $index + 1 ] ); } // 3. Enroll Student Enrollment::updateOrCreate( ['user_id' => $admin->id, 'course_id' => $course1->id], ['enrolled_at' => now(), 'status' => 'active'] ); Enrollment::updateOrCreate( ['user_id' => $admin->id, 'course_id' => $course2->id], ['enrolled_at' => now(), 'status' => 'active'] ); // 4. Progress $lessonToComplete = Lesson::where('slug', 'welcome-n5')->first(); if ($lessonToComplete) { UserProgress::updateOrCreate( ['user_id' => $admin->id, 'lesson_id' => $lessonToComplete->id], ['completed_at' => now()] ); } // 5. Update User Stats $admin->update([ 'xp_points' => 1250, 'current_streak' => 5, ]); } }