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