middleware(function ($request, $next) { $this->form = TimetableForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('edulab.standard.modules'), 'standard', guard_url('standard')); return $next($request); }); } /** * Display a list of timetable. * * @return Response */ public function index(TimetableResourceRequest $request) { $request = $request->all(); $page = TimetableActions::run('paginate', $request); $data = new TimetablesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('standard::timetable.names')) ->view('standard::timetable.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display timetable. * * @param Request $request * @param Model $timetable * * @return Response */ public function show(TimetableResourceRequest $request, Timetable $model) { $form = $this->form; $modules = $this->modules; $data = new TimetableResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('standard::timetable.name')) ->data(compact('data', 'form', 'modules')) ->view('standard::timetable.show') ->output(); } /** * Show the form for creating a new timetable. * * @param Request $request * * @return Response */ public function create(TimetableResourceRequest $request, Timetable $model) { $form = $this->form; $modules = $this->modules; $data = new TimetableResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('standard::timetable.name')) ->view('standard::timetable.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new timetable. * * @param Request $request * * @return Response */ public function store(TimetableResourceRequest $request, Timetable $model) { try { $request = $request->all(); $model = TimetableAction::run('store', $model, $request); $data = new TimetableResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('standard::timetable.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('standard/timetable/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/standard/timetable')) ->redirect(); } } /** * Show timetable for editing. * * @param Request $request * @param Model $timetable * * @return Response */ public function edit(TimetableResourceRequest $request, Timetable $model) { $form = $this->form; $modules = $this->modules; $data = new TimetableResource($model); // return view('standard::timetable.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('standard::timetable.name')) ->view('standard::timetable.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the timetable. * * @param Request $request * @param Model $timetable * * @return Response */ public function update(TimetableResourceRequest $request, Timetable $model) { try { $request = $request->all(); $model = TimetableAction::run('update', $model, $request); $data = new TimetableResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('standard::timetable.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('standard/timetable/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('standard/timetable/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the timetable. * * @param Model $timetable * * @return Response */ public function destroy(TimetableResourceRequest $request, Timetable $model) { try { $request = $request->all(); $model = TimetableAction::run('destroy', $model, $request); $data = new TimetableResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('standard::timetable.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('standard/timetable/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('standard/timetable/' . $model->getRouteKey())) ->redirect(); } } }