update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Customer;
|
||||
|
||||
use App\Support\EmailRecipients;
|
||||
use App\Mail\Customer\ManualCustomerEmail;
|
||||
use App\Mail\Customer\PasswordResetByAdmin;
|
||||
use App\Models\Customer;
|
||||
@@ -93,9 +94,9 @@ class CustomerMailService
|
||||
|
||||
abort_if($subject === '' || $message === '', 422, 'Subject và content không được để trống.');
|
||||
|
||||
$to = $this->parseEmailRecipients($data['to'] ?? null) ?: [$customer->email];
|
||||
$cc = $this->parseEmailRecipients($data['cc'] ?? null);
|
||||
$bcc = $this->parseEmailRecipients($data['bcc'] ?? null);
|
||||
$to = EmailRecipients::parse($data['to'] ?? null) ?: [$customer->email];
|
||||
$cc = EmailRecipients::parse($data['cc'] ?? null);
|
||||
$bcc = EmailRecipients::parse($data['bcc'] ?? null);
|
||||
|
||||
abort_if($to === [], 422, 'Không có địa chỉ email nhận hợp lệ.');
|
||||
|
||||
@@ -129,18 +130,4 @@ class CustomerMailService
|
||||
'customer_id' => $customer->id,
|
||||
]);
|
||||
}
|
||||
|
||||
private function parseEmailRecipients(?string $value): array
|
||||
{
|
||||
if (!$value) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect(preg_split('/[,;]+/', $value) ?: [])
|
||||
->map(fn($email) => trim((string) $email))
|
||||
->filter(fn($email) => $email !== '' && filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user