Skip to content

Instantly share code, notes, and snippets.

@martinbean
Created February 6, 2018 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbean/ffcde746e70a0ad21446a1f47f743fd8 to your computer and use it in GitHub Desktop.
Save martinbean/ffcde746e70a0ad21446a1f47f743fd8 to your computer and use it in GitHub Desktop.
Throw a validation exception with a plain array of errors
<?php
use Illuminate\Validation\ValidationException;
if ($coupon->cannotBeRedeemed()) {
throw ValidationException::withMessages([
'coupon' => [
'The coupon code is invalid.',
],
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment