feat(admin): improve payments and server settings

This commit is contained in:
baodev0
2026-10-19 07:59:23 +07:00
parent 9ed77a85fd
commit ea9a53f742
32 changed files with 680 additions and 78 deletions
+28
View File
@@ -49,6 +49,19 @@ final class MailSettings
return self::resolve()['transport'] ?? null;
}
/**
* @return array{cc: array<int, string>, bcc: array<int, string>}
*/
public static function recipients(): array
{
$settings = self::resolve();
return [
'cc' => $settings['cc'] ?? [],
'bcc' => $settings['bcc'] ?? [],
];
}
public static function refresh(object $mailer): void
{
self::apply();
@@ -91,6 +104,8 @@ final class MailSettings
'transport' => $transport,
'from_address' => ($mail->from_address ?? null) ?: ($mail->user ?? null),
'from_name' => ($mail->from_name ?? null) ?: $company,
'cc' => self::emailList($mail->cc ?? []),
'bcc' => self::emailList($mail->bcc ?? []),
'mailer' => array_filter([
'transport' => $transport,
'host' => $mail->host ?? '',
@@ -102,4 +117,17 @@ final class MailSettings
];
});
}
/**
* @return array<int, string>
*/
private static function emailList(mixed $value): array
{
$emails = is_array($value) ? $value : preg_split('/[,;\s]+/', (string) $value, -1, PREG_SPLIT_NO_EMPTY);
return array_values(array_unique(array_filter(
array_map(fn ($email) => strtolower(trim((string) $email)), $emails ?: []),
fn (string $email) => filter_var($email, FILTER_VALIDATE_EMAIL) !== false,
)));
}
}