【问题标题】:checkout a product VAT ValidationExtensionS Service Provider' not found结帐产品 VAT ValidationExtensionS Service Provider' not found
【发布时间】:2015-09-18 07:59:51
【问题描述】:

我在结帐产品增值税验证时遇到自定义验证问题。

但我运行时出现此错误:

找不到类“App\Providers\ValidationExtensionS Service Provider”。

谁能帮我解决这个问题。

我已在此处附加了我的 valadatorextended.php 文件:

namespace App\Services;
use App\Services\ValidatorExtended;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Validator as IlluminateValidator;
class ValidatorExtended extends IlluminateValidator {
private $_custom_messages = array(
   "vat" => "The :attribute is not a valid VAT.",
   //place for more customized messages
);
public function __construct( $translator, $data, $rules, $messages = array(), $customAttributes = array() ) {
parent::__construct( $translator, $data, $rules, $messages, $customAttributes );

 $this->_set_custom_stuff();
}

protected function _set_custom_stuff() {
   //setup our custom error messages
   $this->setCustomMessages( $this->_custom_messages );
}

protected function validateVat( $attribute, $value ) {
   // You can extend your RegEx with other Countries, if you like

   return (bool) preg_match( "/((DK|FI|HU|LU|MT|SI)(-)?\d{8})|((BE|EE|DE|EL|LT|PT)(-)?\d{9})|((PL|SK)(-)?\d{10})|((IT|LV)(-)?\d{11})|((LT|SE)(-)?\d{12})|(AT(-)?U\d{8})|(CY(-)?\d{8}[A-Z])|(CZ(-)?\d{8,10})|(FR(-)?[\dA-HJ-NP-Z]{2}\d{9})|(IE(-)?\d[A-Z\d]\d{5}[A-Z])|(NL(-)?\d{9}B\d{2})|(ES(-)?[A-Z\d]\d{7}[A-Z\d])/", $value );
  }

   //place for more protected functions for other custom validations

  }

【问题讨论】:

    标签: php laravel-4 custom-validators


    【解决方案1】:

    看起来你在某处搞砸了Use 声明。如果您尝试使用 ValidatorExtended 类,您的 use 语句应如下所示:

    use App\Services\ValidatorExtended;
    

    查看它,您提供的代码似乎不符合给出的错误。

    【讨论】:

    • 是的,我试图从这个构建:laracasts.com/discuss/channels/laravel/…你能帮我弄清楚如何指定路线。
    • 例如:对于其他功能,我有这样的路线:Route::get('bank', array('as' => 'bank','uses' => 'Frontend\CartController @paymentBank'));你能告诉我如何为自定义验证指定路由吗?
    猜你喜欢
    • 2018-05-01
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 2013-06-20
    相关资源
    最近更新 更多