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