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