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