Submit model id and request a prediction (trainedmodels.predict)

@param string $id The unique name for the predictive model.
@param Input $postBody
@return Output
192633
public function predict($id, Input $postBody, $optParams = array()) {
      $params = array('id' => $id, 'postBody' => $postBody);
      $params = array_merge($params, $optParams);
      $data = $this->__call('predict', array($params));
      if ($this->useObjects()) {
        return new Output($data);
      } else {
        return $data;
      }
    }
804827
public function update(SubmitRequest $request, $id = null)
    {
        $id = is_null($id) ? $request->input('id') : $id;
        $this->service->update($id, $request->except(['userType']));

        return $this->success();
    }
466450
public function update($id, $body)
    {
        $request = $this->paystackHttpClient->put(
            $this->transformUrl(Resource::CUSTOMERS_URL, $id),
            [
                'body'  => is_array($body) ? $this->toJson($body) : $body,
            ]
        );

        return $this->processResourceRequestResponse($request);
    }
604313
public function getPostEditPost($id)
    {
        $form = new EditPostForm($this->di, $id);
        $form->check();

        $views = [
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
        ];

        $this->di->get("pageRenderComment")->renderPage([
            "views" => $views,
            "title" => "Edit post | $id"
        ]);
    }
804845
public function editComment(int $id, string $body): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/comments/:id',
            $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $id), Request::METHOD_PATCH, [
                'body' => $body
            ]);
    }
450560
public function train(string $id)
    {
        $modelResult = $this->getRequest()->request(
            'POST',
            $this->getRequestUrl(sprintf('models/%s/versions', $id))
        );

        return $this->getModelFromResult($modelResult);
    }
968283
public function viewAction($id)
    {
        $post = $this->get('opifer.form.post_manager')->getRepository()->find($id);

        if (!$post) {
            return $this->createNotFoundException();
        }

        return $this->render($this->getParameter('opifer_form.post_view_view'), [
            'post' => $post,
        ]);
    }
936530
public function update($id)
    {
        $data = Input::all();

        $isEditable = $this->isEditable($data);

        $data = $this->handleEditable($data);

        $data = $this->handleFileDelete($data);

        if ($this->handleOrderable($id, $data)) {
            return response([
                'status'  => true,
                'message' => trans('admin.update_succeeded'),
            ]);
        }

        /* @var Model $this->model */
        $this->model = $this->model->with($this->getRelations())->findOrFail($id);

        $this->setFieldOriginalValue();

        // Handle validation errors.
        if ($validationMessages = $this->validationMessages($data)) {
            if (!$isEditable) {
                //$name = str_replace('update','edit',\Route::currentRouteName());
                //return redirect()->route($name, [explode('.', $name)[0] => $id])->withInput()->withErrors($validationMessages);
                return back()->withInput()->withErrors($validationMessages);
            } else {
                return response()->json(['errors' => array_dot($validationMessages->getMessages())], 422);
            }
        }

        if (($response = $this->prepare($data)) instanceof Response) {
            return $response;
        }

        DB::transaction(function () {
            $updates = $this->prepareUpdate($this->updates);

            foreach ($updates as $column => $value) {
                /* @var Model $this->model */
                $this->model->setAttribute($column, $value);
            }

            $this->model->save();

            $this->updateRelation($this->relations);
        });

        if (($result = $this->complete($this->saved)) instanceof Response) {
            return $result;
        }

        if ($response = $this->ajaxResponse(trans('admin.update_succeeded'))) {
            return $response;
        }

        return $this->redirectAfterUpdate();
    }
1049684
public function postFormPostAction(Request $request, $id)
    {
        /** @var Form $form */
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

        if (!$form) {
            throw $this->createNotFoundException('The form could not be found');
        }

        $data = json_decode($request->getContent(), true);

        $token = $data['_token'];
        if ($this->isCsrfTokenValid($form->getName(), $token)) {
            throw new InvalidCsrfTokenException();
        }

        // Remove the token from the data array, since it's not part of the form.
        unset($data['_token']);
        // We're stuck with a legacy form structure here, which we'd like to hide on the API.
        $data = ['valueset' => ['namedvalues' => $data]];

        /** @var Post $post */
        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $post->setForm($form);

        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id, 'csrf_protection' => false]);
        $postForm->submit($data);

        if ($postForm->isSubmitted() && $postForm->isValid()) {
            $this->get('opifer.form.post_manager')->save($post);

            return new JsonResponse(['message' => 'Success'], 201);
        }

        return new JsonResponse([
            'errors' => (string) $postForm->getErrors()
        ], 400);
    }
475671
public function update($id)
    {
        $block = $this->repository->getById($id);
        if (!empty($block)) {
            $this->authorize('update', $block);
            $input = $this->validator->validate('update');
            $block = $this->repository->update($block, $input, auth()->user());
            return $this->respondWithSuccess($block, new BlockTransformer);
        }
        return $this->respondNotFound();
    }
195685
public function rawPost($id) {
		$item = $this->dataService->byId('MicroPost', $id);
		if ($item->checkPerm('Write')) {
			return $item;
		}
	}
283307
public function editAction($id = null)
    {
        $request = $this->getRequest();
        // the key used to lookup the template
        $templateKey = 'edit';

        $id = $request->get($this->admin->getIdParameter());
        $existingObject = $this->admin->getObject($id);

        if (!$existingObject) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id: %s', $id));
        }

        $this->checkParentChildAssociation($request, $existingObject);

        $this->admin->checkAccess('edit', $existingObject);

        $preResponse = $this->preEdit($request, $existingObject);
        if (null !== $preResponse) {
            return $preResponse;
        }

        $this->admin->setSubject($existingObject);
        $objectId = $this->admin->getNormalizedIdentifier($existingObject);

        $form = $this->admin->getForm();

        if (!\is_array($fields = $form->all()) || 0 === \count($fields)) {
            throw new \RuntimeException(
                'No editable field defined. Did you forget to implement the "configureFormFields" method?'
            );
        }

        $form->setData($existingObject);
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $isFormValid = $form->isValid();

            // persist if the form was valid and if in preview mode the preview was approved
            if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
                $submittedObject = $form->getData();
                $this->admin->setSubject($submittedObject);

                try {
                    $existingObject = $this->admin->update($submittedObject);

                    if ($this->isXmlHttpRequest()) {
                        return $this->renderJson([
                            'result' => 'ok',
                            'objectId' => $objectId,
                            'objectName' => $this->escapeHtml($this->admin->toString($existingObject)),
                        ], 200, []);
                    }

                    $this->addFlash(
                        'sonata_flash_success',
                        $this->trans(
                            'flash_edit_success',
                            ['%name%' => $this->escapeHtml($this->admin->toString($existingObject))],
                            'SonataAdminBundle'
                        )
                    );

                    // redirect to edit mode
                    return $this->redirectTo($existingObject);
                } catch (ModelManagerException $e) {
                    $this->handleModelManagerException($e);

                    $isFormValid = false;
                } catch (LockException $e) {
                    $this->addFlash('sonata_flash_error', $this->trans('flash_lock_error', [
                        '%name%' => $this->escapeHtml($this->admin->toString($existingObject)),
                        '%link_start%' => '<a href="'.$this->admin->generateObjectUrl('edit', $existingObject).'">',
                        '%link_end%' => '</a>',
                    ], 'SonataAdminBundle'));
                }
            }

            // show an error message if the form failed validation
            if (!$isFormValid) {
                if (!$this->isXmlHttpRequest()) {
                    $this->addFlash(
                        'sonata_flash_error',
                        $this->trans(
                            'flash_edit_error',
                            ['%name%' => $this->escapeHtml($this->admin->toString($existingObject))],
                            'SonataAdminBundle'
                        )
                    );
                }
            } elseif ($this->isPreviewRequested()) {
                // enable the preview template if the form was valid and preview was requested
                $templateKey = 'preview';
                $this->admin->getShow();
            }
        }

        $formView = $form->createView();
        // set the theme for the current Admin Form
        $this->setFormTheme($formView, $this->admin->getFormTheme());

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate($templateKey);
        // $template = $this->templateRegistry->getTemplate($templateKey);

        return $this->renderWithExtraParams($template, [
            'action' => 'edit',
            'form' => $formView,
            'object' => $existingObject,
            'objectId' => $objectId,
        ], null);
    }
235541
public function init(Request $request, $postType, $id, $subPostType)
	{
		// Lets validate if the post type exists and if so, continue.
		$postTypeModel = $this->getPostType($postType);
		if(!$postTypeModel){
    		$errorMessages = 'You are not authorized to do this.';
    		return $this->abort($errorMessages);
    	}

		// Check if the post type has a identifier
    	if(empty($postTypeModel->identifier)){
    		$errorMessages = 'The post type does not have a identifier.';
    		if(array_has($postTypeModel->errorMessages, 'post_type_identifier_does_not_exist')){
    			$errorMessages = $postTypeModel->errorMessages['post_type_identifier_does_not_exist'];
    		}
    		return $this->abort($errorMessages);
    	}

		$post = $this->findPostInstance($postTypeModel, $request, $postType, $id, 'show_post');
		if(!$post){
			$errorMessages = 'Post does not exist.';
			if(array_has($postTypeModel->errorMessages, 'post_does_not_exist')){
				$errorMessages = $postTypeModel->errorMessages['post_does_not_exist'];
			}
			return $this->abort($errorMessages);
		}

		// Lets get the post type of the sub post type object
		$subPostTypeModel = $this->getPostType($subPostType);
		if(!$subPostTypeModel){
			$errorMessages = 'You are not authorized to do this.';
    		if(array_has($postTypeModel->errorMessages, 'sub_post_type_does_not_exist')){
    			$errorMessages = $postTypeModel->errorMessages['sub_post_type_does_not_exist'];
    		}
    		return $this->abort($errorMessages);
		}

		$collection = collect([
			'objects' => $post->posts()->where('post_type', '=', $subPostTypeModel->identifier)->get()->toArray(),
		]);

		// Returning the full collection
		return response()->json($collection);
	}
510136
public function fireEdit($id, $payload = [])
    {
        if (! method_exists($this, 'onEdit')) {
            return;
        }

        $payload = array_merge(['id' => $id], ['payload' => $payload]);

        $form = $this->app->call([$this, 'onEdit'], $payload);

        if ($form instanceof DisplayInterface) {
            $form->setModelClass($this->getClass());
        }

        if ($form instanceof Initializable) {
            $form->initialize();
        }

        if ($form instanceof FormInterface) {
            $form->setAction($this->getUpdateUrl($id));
            $form->setId($id);
        }

        return $form;
    }
238986
public function update($id)
	{
		$messages = $this->posts->validForUpdate($id, Input::get('title'), Input::get('slug'));

		if (count($messages) > 0)
		{
			return Response::json($messages->all(), 400);
		}

		$post = $this->posts->update(
			$id,
			Input::get('title'),
			Input::get('content'),
			Input::get('slug'),
			explode(',', Input::get('tags')),
			(bool) Input::get('active'),
			(int) Input::get('user_id'),
			Carbon::createFromTimestamp(strtotime(Input::get('publish_date')))
		);

		return (string) $this->posts->find($id);
	}
696416
public function submitAction(Request $request, $id)
    {
        /** @var Form $form */
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

        if (!$form) {
            throw $this->createNotFoundException('The form could not be found');
        }

        $spamFree = true;
        if ($form->isRecaptchaEnabled() && $recaptchaSecretKey = $this->getParameter('opifer_form.recaptcha_secret_key')) {
            $responseKey = $request->get('g-recaptcha-response');
            if (!$responseKey) {
                $spamFree = false;
            }
            $recaptcha = new ReCaptcha($recaptchaSecretKey);
            $response = $recaptcha->verify($responseKey, $_SERVER['REMOTE_ADDR']);
            if (!$response->isSuccess()) {
                $spamFree = false;
            }
        }

        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $post->setForm($form);

        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);
        $postForm->handleRequest($request);

        if ($postForm->isSubmitted() && $postForm->isValid() && $spamFree) {
            $this->get('opifer.form.post_manager')->save($post);

            $event = new FormSubmitEvent($post);
            $this->get('event_dispatcher')->dispatch(Events::POST_FORM_SUBMIT, $event);
            
            if ($form->getRedirectUrl()) {
                return $this->redirect($form->getRedirectUrl());
            }
        }

        return $this->redirect($request->headers->get('referer'));
    }
269256
public function read($id)
    {
        $this->preRead($id);
        $result = $this->dataStore->read($id);

        return $this->postRead($result, $id);
    }