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