Skip to content

Instantly share code, notes, and snippets.

@NightZpy
Created May 22, 2015 10:25
Show Gist options
  • Save NightZpy/139c9062d93ed4a87bcf to your computer and use it in GitHub Desktop.
Save NightZpy/139c9062d93ed4a87bcf to your computer and use it in GitHub Desktop.
try
{
$this->registerChangeForm->validate($input);
$change = $this->changeRepository->create($input);
$this->setSuccess(true);
$this->addToResponseArray('change', $change);
$this->addToResponseArray('data', $input);
return $this->getResponseArrayJson();
}
catch (FormValidationException $e)
//cambiarlo por
try
{
$this->registerChangeForm->validate($input);
$change = $this->changeRepository->create($input);
$this->setSuccess(($change ? true : false));
$this->addToResponseArray('data', ($change ? $change : $input));
return $this->getResponseArrayJson();
}
catch (FormValidationException $e)
{
$this->setSuccess(false);
$this->addToResponseArray('data', $input);
$this->addToResponseArray('errors', $e->getErrors()->all());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment