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