/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit($id) { $lessonsSubjects = $this->currentUser->lessons()->groupBy('subject_id')->lists('subject_id'); $tutoring = Tutoring::findOrFail($id); $subjects = Subject::whereIn('id', array_flatten($lessonsSubjects))->get(); $modules = Module::whereIn('subject_id', array_flatten($subjects->lists('id')))->get()->map(function ($module) { return (object) ['id' => $module->id, 'name' => "N. {$module->num} - {$module->short_description}", 'subject_id' => $module->subject_id]; }); $classes = $this->currentUser->lessons()->groupBy('class_id')->get()->map(function ($lesson) { return $lesson->schoolClass; }); return view('tutoring.edit', compact('tutoring', 'subjects', 'modules', 'classes')); }
/** * Show the form for editing the specified resource. * * @param $teacherId * @param $lessonId * * @return Response */ public function edit($teacherId, $lessonId) { $teacher = User::findOrFail($teacherId); $lesson = Lesson::findOrFail($lessonId); $subjects = Subject::all(); $classes = SchoolClass::all(); $days = Lesson::getDays(); $adTeachers = Group::findOrFail(3)->users->except($teacherId)->map(function ($user) { return ['id' => $user->id, 'name' => $user->fullName()]; }); $adTeacher = $lesson->teachers->except($teacher->id)->first(); return view('lesson.edit', compact('teacher', 'lesson', 'subjects', 'classes', 'days', 'adTeachers', 'adTeacher')); }
public function __construct(Auth $auth) { parent::__construct($auth); $lessonsSubjects = $this->currentUser->lessons()->groupBy('subject_id')->lists('subject_id'); $this->teacherSubjects = Subject::whereIn('id', array_flatten($lessonsSubjects))->get(); }