/** * Get the response for a forbidden operation. * * @return \Illuminate\Http\Response */ public function forbiddenResponse() { $total = Unit::findOrFail($this->get('unit_id'))->evaluations->sum('value'); $message = trans('messages.the_maximum_value_of_evaluation', ['value' => 100 - $total]); Flash::info($message); return redirect()->route('teacher.evaluations.create')->withInput(); }
/** * Show the form for creating a new resource. * * @param Request $request * @return $this */ public function create(Request $request) { if ($request->has('unit')) { $units = Unit::findOrFail($request->get('unit'))->course->units->lists('title', 'id'); } else { $units = Unit::where('user_id', Auth::user()->id)->lists('title', 'id'); } return view('teacher.questions.create')->with('units', $units)->with('title', trans('titles.create_new_question')); }
/** * Remove the specified resource from storage. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $unit = Unit::findOrFail($id); $unit->delete(); $message = trans('messages.unit_successfully_removed'); Flash::info($message); return redirect()->route('teacher.courses.show', $unit->course); }
/** * @param Route $route */ public function __construct(Route $route) { $this->route = $route; $this->course = Unit::findOrFail($route->getParameter('units'))->course->id; }
/** * Display the specified resource. * * @param int $id * @param ShowUnitRequest|Request $request * @return Response */ public function show($id, ShowUnitRequest $request) { $unit = Unit::findOrFail($id); return view('units.show')->with('unit', $unit)->with('title', $unit->title); }