public function lesson(Lesson $Lesson, $id) { if (!($lesson = $Lesson->student()->with(['elements' => function ($query) { $query->where('state', 'نشط')->orderBy('element_order', 'asc'); }])->findOrFail($id))) { return redirect()->route('students.profile.subjects.index'); } $lessons_arr = Lesson::where('subject_subject_id', $lesson->subject_subject_id)->orderBy('lesson_order', 'ASC')->get()->toArray(); $this->makeSubjectLessonsMenu($lesson->subject_subject_id, $lessons_arr); return view('students::profile.subjects.lesson', compact('lesson')); }