diff --git a/src/Provider.php b/src/Provider.php index e07d679..c32dacf 100644 --- a/src/Provider.php +++ b/src/Provider.php @@ -36,13 +36,9 @@ public function boot(): void public function registerValidationRules(): void { - $currency_code = null; - - Validator::extend('currency_code', function ($attribute, $value, $parameters, $validator) use(&$currency_code) { + Validator::extend('currency_code', function ($attribute, $value, $parameters, $validator) { $status = false; - $currency_code = $value; - $currencies = config('money.currencies'); if (array_key_exists($value, $currencies)) { @@ -50,9 +46,11 @@ public function registerValidationRules(): void } return $status; - }, - trans('validation.custom.invalid_currency', ['attribute' => $currency_code]) - ); + }); + + Validator::replacer('currency_code', function($message, $attribute, $rule, $parameters) { + return trans('validation.custom.invalid_currency', ['attribute' => $attribute]); + }); } public function registerBladeDirectives(): void