Add trait

This commit is contained in:
philipp lang 2023-03-03 00:22:08 +01:00
parent e6aa98c558
commit 2e56f4d305
2 changed files with 24 additions and 1 deletions

23
src/HasPhoneNumbers.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace Zoomyboy\Phone;
trait HasPhoneNumbers
{
/**
* @return array<int, string>
*/
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;
}
}

View File

@ -38,6 +38,6 @@ class ValidPhoneRule implements Rule
*/ */
public function message() public function message()
{ {
return __('validation.phone_number', ['name' => $this->attribute]); return __('validation.phone_number', ['attribute' => $this->attribute]);
} }
} }