/** * Handle the command. * * @param ResponseFactory $response * @param ActionResponder $responder */ public function handle(ResponseFactory $response, ActionResponder $responder) { $data = new Collection(); if ($action = $this->builder->getActiveFormAction()) { $responder->setFormResponse($this->builder, $action); $original = $this->builder->getFormResponse(); if ($original instanceof RedirectResponse) { $data->put('redirect', $original->getTargetUrl()); } } $data->put('success', !$this->builder->hasFormErrors()); $data->put('errors', $this->builder->getFormErrors()->toArray()); $this->builder->setFormResponse($response = $response->json($data)); }
/** * Handle the command. * * @param Request $request * @param MessageBag $messages * @param Translator $translator */ public function handle(Request $request, MessageBag $messages, Translator $translator) { if ($this->builder->isAjax()) { return; } $errors = $this->builder->getFormErrors(); $messages->error($errors->all()); if ($request->segment(1) == 'admin' && ($stream = $this->builder->getFormStream()) && $stream->isTrashable()) { /* @var AssignmentInterface $assignment */ foreach ($stream->getUniqueAssignments() as $assignment) { if ($this->builder->hasFormError($assignment->getFieldSlug())) { $messages->warning($translator->trans('streams::validation.unique_trash', ['attribute' => '"' . $translator->trans($assignment->getFieldName()) . '"'])); } } } }
/** * Handle the command. * * @param ResponseFactory $response */ public function handle(ResponseFactory $response) { $this->builder->setFormResponse($response->json(['errors' => $this->builder->getFormErrors()->getMessages(), 'redirect' => $this->builder->getFormOption('redirect', $this->builder->getFormActions()->active()->getRedirect())])); }
/** * Handle the event. * * @param Store $session */ public function handle(Store $session) { $session->flash($this->builder->getOption('prefix') . 'errors', $this->builder->getFormErrors()); }