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