diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 9bfbc70930c5..a2f58fb5a931 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -21,6 +21,7 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; use Illuminate\Database\Eloquent\RelationNotFoundException; +use Illuminate\Database\QueryException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Http\Request; @@ -204,7 +205,11 @@ class Handler extends ExceptionHandler return response()->json(['message' => $exception->getMessage()], 400); } elseif ($exception instanceof StripeConnectFailure) { return response()->json(['message' => $exception->getMessage()], 400); - } + } elseif ($exception instanceof QueryException) { + return response()->json(['message' => 'The was a problem executing this query.'], 500); + } + + return parent::render($request, $exception); } diff --git a/app/Http/Requests/BankIntegration/StoreBankIntegrationRequest.php b/app/Http/Requests/BankIntegration/StoreBankIntegrationRequest.php index 2f1902f43ac3..67e209731b63 100644 --- a/app/Http/Requests/BankIntegration/StoreBankIntegrationRequest.php +++ b/app/Http/Requests/BankIntegration/StoreBankIntegrationRequest.php @@ -32,7 +32,9 @@ class StoreBankIntegrationRequest extends Request public function rules() { - $rules = []; + $rules = [ + 'bank_account_name' => 'required|min:3' + ]; return $rules; } @@ -41,6 +43,9 @@ class StoreBankIntegrationRequest extends Request { $input = $this->all(); + if(!array_key_exists('provider_name', $input) || strlen($input['provider_name']) == 0) + $input['provider_name'] = $input['bank_account_name']; + $this->replace($input); }