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