diff --git a/src/HasPhoneNumbers.php b/src/HasPhoneNumbers.php new file mode 100644 index 0000000..82fbf7d --- /dev/null +++ b/src/HasPhoneNumbers.php @@ -0,0 +1,23 @@ + + */ + abstract public function phoneNumbers(): array; + + public function updatePhoneNumbers(): self + { + foreach ($this->phoneNumbers() as $property) { + $this->setAttribute( + $property, + app(Formatter::class)->format($this->getAttribute($property)) + ); + } + + return $this; + } +} diff --git a/src/ValidPhoneRule.php b/src/ValidPhoneRule.php index 25d4da6..5d57e4a 100644 --- a/src/ValidPhoneRule.php +++ b/src/ValidPhoneRule.php @@ -38,6 +38,6 @@ class ValidPhoneRule implements Rule */ public function message() { - return __('validation.phone_number', ['name' => $this->attribute]); + return __('validation.phone_number', ['attribute' => $this->attribute]); } }