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