- Added localization support for API responses in English and Spanish. - Introduced a middleware to set the API locale based on the Accept-Language header. - Updated various exception messages and validation responses to use localized strings. - Created new language files for English and Spanish translations. - Refactored existing code to replace hardcoded messages with localized strings. - Added tests to verify localization functionality and response correctness.
36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\MailTest\Services;
|
|
|
|
use App\Domains\Integration\Services\MailService;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
|
|
class MailTestService
|
|
{
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function send(Tenant $tenant, string $recipient, ?string $subject = null, ?string $message = null): array
|
|
{
|
|
$subject ??= 'Prueba de correo de Shopit';
|
|
$message ??= 'Este es un correo de prueba enviado desde Shopit.';
|
|
|
|
$mailService = (new MailService)->forTenant($tenant->codigo);
|
|
$mailService->send(
|
|
$recipient,
|
|
$subject,
|
|
'<h1 style="margin: 0 0 20px;">'.e($subject).'</h1>'
|
|
.'<p>'.nl2br(e($message)).'</p>',
|
|
);
|
|
|
|
return [
|
|
'code' => 'mail.test_sent',
|
|
'message' => __('api.mail.test_sent'),
|
|
'recipient' => $recipient,
|
|
'tenant_code' => $tenant->codigo,
|
|
'mailer' => $mailService->mailerName(),
|
|
'sent_at' => now()->toIso8601String(),
|
|
];
|
|
}
|
|
}
|