repository = $company_setting; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\CompanySetting\Repositories\Criteria\CompanySettingResourceCriteria::class); } /** * Display a list of company_setting. * * @return Response */ public function index(CompanySettingRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\CompanySetting\Repositories\Presenter\CompanySettingPresenter::class) ->$function(); } $company_settings = $this->repository->paginate(); return $this->response->title(trans('company_setting::company_setting.names')) ->view('company_setting::company_setting.index', true) ->data(compact('company_settings')) ->output(); } /** * Display company_setting. * * @param Request $request * @param Model $company_setting * * @return Response */ public function show(CompanySettingRequest $request, CompanySetting $company_setting) { if ($company_setting->exists) { $view = 'company_setting::company_setting.show'; } else { $view = 'company_setting::company_setting.new'; } return $this->response->title(trans('app.view') . ' ' . trans('company_setting::company_setting.name')) ->data(compact('company_setting')) ->view($view, true) ->output(); } /** * Show the form for creating a new company_setting. * * @param Request $request * * @return Response */ public function create(CompanySettingRequest $request) { $company_setting = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('company_setting::company_setting.name')) ->view('company_setting::company_setting.create', true) ->data(compact('company_setting')) ->output(); } /** * Create new company_setting. * * @param Request $request * * @return Response */ public function store(CompanySettingRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $company_setting = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('company_setting::company_setting.name')])) ->code(204) ->status('success') ->url(guard_url('company_setting/company_setting/' . $company_setting->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/company_setting/company_setting')) ->redirect(); } } /** * Show company_setting for editing. * * @param Request $request * @param Model $company_setting * * @return Response */ public function edit(CompanySettingRequest $request, CompanySetting $company_setting) { return $this->response->title(trans('app.edit') . ' ' . trans('company_setting::company_setting.name')) ->view('company_setting::company_setting.edit', true) ->data(compact('company_setting')) ->output(); } /** * Update the company_setting. * * @param Request $request * @param Model $company_setting * * @return Response */ public function update(CompanySettingRequest $request, CompanySetting $company_setting) { try { $attributes = $request->all(); $company_setting->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('company_setting::company_setting.name')])) ->code(204) ->status('success') ->url(guard_url('company_setting/company_setting/' . $company_setting->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('company_setting/company_setting/' . $company_setting->getRouteKey())) ->redirect(); } } /** * Remove the company_setting. * * @param Model $company_setting * * @return Response */ public function destroy(CompanySettingRequest $request, CompanySetting $company_setting) { try { $company_setting->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('company_setting::company_setting.name')])) ->code(202) ->status('success') ->url(guard_url('company_setting/company_setting/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('company_setting/company_setting/' . $company_setting->getRouteKey())) ->redirect(); } } /** * Remove multiple company_setting. * * @param Model $company_setting * * @return Response */ public function delete(CompanySettingRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('company_setting::company_setting.name')])) ->status("success") ->code(202) ->url(guard_url('company_setting/company_setting')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/company_setting/company_setting')) ->redirect(); } } /** * Restore deleted company_settings. * * @param Model $company_setting * * @return Response */ public function restore(CompanySettingRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('company_setting::company_setting.name')])) ->status("success") ->code(202) ->url(guard_url('/company_setting/company_setting')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/company_setting/company_setting/')) ->redirect(); } } }