diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 4ce8322d45fd..79e78569714b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -118,6 +118,7 @@ class Handler extends ExceptionHandler } elseif ($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()) { return response()->json(['message'=>'Method not support for this route'], 404); } elseif ($exception instanceof ValidationException && $request->expectsJson()) { +// info(print_r($exception->validator->getMessageBag(),1)); return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422); } elseif ($exception instanceof RelationNotFoundException && $request->expectsJson()) { return response()->json(['message' => $exception->getMessage()], 400); diff --git a/app/Http/ValidationRules/Credit/ValidCreditsRules.php b/app/Http/ValidationRules/Credit/ValidCreditsRules.php index 1cdaf11eca44..5e7a51d4522c 100644 --- a/app/Http/ValidationRules/Credit/ValidCreditsRules.php +++ b/app/Http/ValidationRules/Credit/ValidCreditsRules.php @@ -78,6 +78,10 @@ class ValidCreditsRules implements Rule } + if(count($this->input['credits']) >=1 && count($this->input['invoices']) == 0) + $this->error_msg = "You must have an invoice set when using a credit"; + return false; + return true; }