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