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