From c483ab88b5e279f91fd76f2f493502242fe24e86 Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Fri, 19 Dec 2025 01:13:10 +0100 Subject: [PATCH] bugfix --- app/Services/Course/CoursePlayerService.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/Services/Course/CoursePlayerService.php b/app/Services/Course/CoursePlayerService.php index cd824513..6f94ae76 100644 --- a/app/Services/Course/CoursePlayerService.php +++ b/app/Services/Course/CoursePlayerService.php @@ -16,8 +16,8 @@ class CoursePlayerService { $user = Auth::user(); - return $watching_type === 'lesson' ? - SectionLesson::with([ + if ($watching_type === 'lesson') { + return SectionLesson::with([ 'resources', 'forums' => function ($query) { $query->with([ @@ -27,13 +27,15 @@ class CoursePlayerService }, ]); }, - ])->find($lesson_id) : - SectionQuiz::with([ - 'quiz_questions', - 'quiz_submissions' => function ($query) use ($user) { - $query->where('user_id', $user->id); - } - ])->find($lesson_id); + ])->findOrFail($lesson_id); + } + + return SectionQuiz::with([ + 'quiz_questions', + 'quiz_submissions' => function ($query) use ($user) { + $query->where('user_id', $user->id); + } + ])->findOrFail($lesson_id); } function getWatchHistory(string $course_id, ?string $user_id): ?WatchHistory