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