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