/** * 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 ActionResponder $responder */ public function handle(ActionResponder $responder) { $actions = $this->builder->getFormActions(); if ($this->builder->getFormResponse()) { return; } if ($this->builder->hasFormErrors()) { return; } if (!$this->builder->canSave()) { return; } if ($action = $actions->active()) { $responder->setFormResponse($this->builder, $action); } }