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