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