app/Http/Controllers/Controller.php
/**
     * Returns a properly formatted JSON response for a ValidationException
     *
     * @param ValidationException $e
     * @param int                 $status
     *
     * @return \Illuminate\Http\JsonResponse
     */
Returns a properly formatted JSON response for a ValidationException
@param ValidationException $e
@param int                 $status


Returns a properly formatted JSON response for a ValidationException @param ValidationException $e @param int $status
protected function validationErrorToResponse(ValidationException $e, int $status = 400)
    {
        $response = [
            'status' => $status,
            'code' => ResponseStatus::VALIDATION_FAILED,
            'title' => 'Some validation errors were encountered while processing your request',
            'source' => validation_errors_to_messages($e)
        ];
        return response()->json(['errors' => [$response]], $status);
    }
protected function validationErrorToResponse ( ValidationException $ e , int $ status = 400 ) { $ response = [ 'status' => $ status , 'code' => ResponseStatus :: VALIDATION_FAILED , 'title' => 'Some validation errors were encountered while processing your request' , 'source' => validation_errors_to_messages ( $ e ) ] ; return response ( ) -> json ( [ 'errors' => [ $ response ] ] , $ status ) ; }
Returns a properly formatted JSON response for a ValidationException
 @param ValidationException $e
 @param int                 $status
Returns a properly formatted JSON response for a ValidationException @param ValidationException $e @param int $status
# convert the error