Add trait
This commit is contained in:
parent
e6aa98c558
commit
2e56f4d305
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue