/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit($id) { $test = $this->currentUser->tests()->findOrFail($id); $subjects = $this->teacherSubjects; $modules = Module::whereIn('subject_id', array_flatten($subjects->lists('id')))->get()->map(function ($module) { return ['id' => $module->id, 'name' => "N. {$module->num} - {$module->short_description}"]; }); $classes = $this->currentUser->lessons()->groupBy('class_id')->get()->map(function ($lesson) { return $lesson->schoolClass; }); return view('test.edit', compact('test', 'modules', 'classes')); }
/** * 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')); }
/** * Remove the specified resource from storage. * * @param int $id * * @return Response */ public function destroy($id) { Module::findOrFail($id)->delete(); return redirect(action('ModuleController@index')); }