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