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