public function show(Course $course) { if (Enroll::where(['course_id' => $course->id, 'user_id' => Auth::user()->id])->ongoing()->exists() and $course->published()) { $lecture = $course->lectures()->first(); $comments = $lecture->comments()->latest('created_at')->get(); return view('courses.course', compact('course', 'lecture', 'comments')); } return view('courses.show', compact('course')); }