From e4d0ac907254a972e7a4f495d133817543842aeb Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Fri, 19 Dec 2025 01:20:45 +0100 Subject: [PATCH] bugfix --- app/Http/Controllers/Course/PlayerController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Course/PlayerController.php b/app/Http/Controllers/Course/PlayerController.php index 28e01f7d..38976e3c 100644 --- a/app/Http/Controllers/Course/PlayerController.php +++ b/app/Http/Controllers/Course/PlayerController.php @@ -10,6 +10,7 @@ use App\Services\Course\CourseReviewService; use App\Services\Course\CourseService; use App\Services\Course\CourseSectionService; use App\Services\LiveClass\ZoomLiveService; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Facades\Auth; use Inertia\Inertia; @@ -50,10 +51,10 @@ class PlayerController extends Controller $section_id = $watch_history->current_section_id; $watching_id = $lesson_id ?? $watch_history->current_watching_id; - $watching_type = $type; // Use the route parameter, not old watch history + $watching_type = $watch_history->current_watching_type ?? $type; $course = $this->courseService->getUserCourseById($watch_history->course_id, $user); - $watching = $this->coursePlay->getWatchingLesson($lesson_id, $type); + $watching = $this->coursePlay->getWatchingLesson($watching_id, $watching_type); $reviews = $this->reviewService->getReviews(['course_id' => $course->id, ...$request->all()], true); $userReview = $this->reviewService->userReview($course->id, $user->id); $totalReviews = $this->reviewService->totalReviews($course->id); @@ -89,6 +90,8 @@ class PlayerController extends Controller 'totalReviews' => $totalReviews, 'zoomConfig' => $zoomConfig, ]); + } catch (ModelNotFoundException $th) { + return redirect()->route('category.courses', ['category' => 'all'])->with('error', 'The requested content could not be found.'); } catch (\Throwable $th) { return redirect()->route('category.courses', ['category' => 'all'])->with('error', $th->getMessage()); }