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