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