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