diff --git a/src/Rules/Money.php b/src/Rules/Money.php index ba0ec76..ca41053 100644 --- a/src/Rules/Money.php +++ b/src/Rules/Money.php @@ -12,16 +12,6 @@ class Money implements Rule { use WithParameters; - /** - * The callback that should be used to validate the locale. - */ - public static $localeCallback; - - /** - * The callback that should be used to validate the currency. - */ - public static $currencyCallback; - /** * Determine if the validation rule passes. */ @@ -38,22 +28,6 @@ public function message(): string return Helpers::getMessage('money'); } - /** - * Set callback to get locale to be used in the validation rule. - */ - public static function setLocaleCallback(callable $callback): void - { - static::$localeCallback = $callback; - } - - /** - * Set callback to get currency to be used in the validation rule. - */ - public static function setCurrencyCallback(callable $callback): void - { - static::$currencyCallback = $callback; - } - /** * Determine if the money is valid. */ @@ -71,9 +45,7 @@ private function checkMoney(mixed $value): bool */ private function getLocale(): mixed { - $default = data_get($this->parameters, '1'); - - return with($default, static::$localeCallback); + return data_get($this->parameters, '1'); } /** @@ -81,8 +53,6 @@ private function getLocale(): mixed */ private function getCurrency(): mixed { - $default = data_get($this->parameters, '0', 'USD'); - - return with($default, static::$currencyCallback); + return data_get($this->parameters, '0', 'USD'); } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 716e14f..0abb3fa 100755 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -68,7 +68,9 @@ private function bootRules(): void return $rule->passes($attribute, $value); }; - $this->app['validator']->extend($name, $extension, $rule->message()); + $this->app['validator']->extend($name, $extension); + + $this->app['validator']->replacer($name, fn () => $rule->message()); }); }