diff --git a/app/DTOs/ContactFormResponse.php b/app/DTOs/ContactFormResponse.php index 123b696b..d4664410 100644 --- a/app/DTOs/ContactFormResponse.php +++ b/app/DTOs/ContactFormResponse.php @@ -12,6 +12,7 @@ public function __construct( public string $subject, public string $response, public string $messageDescription, + public string $locale, ) {} public static function fromArray(ContactForm $record, array $data): self @@ -20,6 +21,7 @@ public static function fromArray(ContactForm $record, array $data): self subject: $data["responseTopic"], response: $data["response"], messageDescription: $record->message, + locale: $record->lang, ); } } diff --git a/app/Filament/Resources/ContactFormResource/Actions/RespondToContactFormMessageAction.php b/app/Filament/Resources/ContactFormResource/Actions/RespondToContactFormMessageAction.php index 21537510..6aa11ceb 100644 --- a/app/Filament/Resources/ContactFormResource/Actions/RespondToContactFormMessageAction.php +++ b/app/Filament/Resources/ContactFormResource/Actions/RespondToContactFormMessageAction.php @@ -48,6 +48,8 @@ protected function setUp(): void ->required(), ]) ->action(function (ContactForm $record, array $data): void { + app()->setLocale($record->lang); + $details = ContactFormResponse::fromArray($record, $data); Mail::to($record->email)->send(new ContactFormResponded($details)); diff --git a/app/Http/Requests/StoreRequest.php b/app/Http/Requests/StoreRequest.php index c9943b49..f1f24def 100644 --- a/app/Http/Requests/StoreRequest.php +++ b/app/Http/Requests/StoreRequest.php @@ -26,6 +26,7 @@ public function data(): array "email" => $this->get("email"), "topic" => $this->get("topic"), "message" => $this->get("message"), + "lang" => app()->getLocale(), ]; } } diff --git a/app/Mail/ContactFormResponded.php b/app/Mail/ContactFormResponded.php index cd9eaf46..346c20ba 100644 --- a/app/Mail/ContactFormResponded.php +++ b/app/Mail/ContactFormResponded.php @@ -21,6 +21,7 @@ public function __construct( public function build(): self { return $this->subject($this->details->subject) - ->view("email"); + ->view("email") + ->with(["details" => $this->details]); } } diff --git a/app/Models/ContactForm.php b/app/Models/ContactForm.php index 89bf1af6..c2071ede 100644 --- a/app/Models/ContactForm.php +++ b/app/Models/ContactForm.php @@ -12,6 +12,7 @@ * @property string $email * @property string $topic * @property string $message + * @property string $lang * @property ContactFormStatus $status */ class ContactForm extends Model @@ -24,6 +25,7 @@ class ContactForm extends Model "message", "status", "response", + "lang", ]; protected $casts = [ "status" => ContactFormStatus::class, diff --git a/database/migrations/2024_10_16_083511_add_lang_column_in_contact_forms_table.php b/database/migrations/2024_10_16_083511_add_lang_column_in_contact_forms_table.php new file mode 100644 index 00000000..c1d655f3 --- /dev/null +++ b/database/migrations/2024_10_16_083511_add_lang_column_in_contact_forms_table.php @@ -0,0 +1,23 @@ +string("lang")->default("pl"); + }); + } + + public function down(): void + { + Schema::table("contact_forms", function (Blueprint $table): void { + $table->dropColumn("lang"); + }); + } +}; diff --git a/docker-compose.yml b/docker-compose.yml index bbdea448..c5d1b04d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,7 +81,7 @@ services: - website-dev - traefik-proxy-blumilk-local ports: - - ${DOCKER_MAILPIT_DASHBOARD_HOST_PORT:-63854}:8025 + - ${DOCKER_MAILPIT_DASHBOARD_HOST_PORT:-34622}:8025 restart: unless-stopped redis: diff --git a/lang/en/email.php b/lang/en/email.php new file mode 100644 index 00000000..ee43d12b --- /dev/null +++ b/lang/en/email.php @@ -0,0 +1,10 @@ + "Response to contact form", + "header" => "Response from contact form", + "your_message" => "Your message", + "response" => "Response", +]; diff --git a/lang/pl/email.php b/lang/pl/email.php new file mode 100644 index 00000000..da93f225 --- /dev/null +++ b/lang/pl/email.php @@ -0,0 +1,10 @@ + "Odpowiedź na formularz kontaktowy", + "header" => "Odpowiedź z formularza kontaktowego", + "your_message" => "Twoja wiadomość", + "response" => "Odpowiedź", +]; diff --git a/resources/views/email.blade.php b/resources/views/email.blade.php index d3b598aa..e4549e5b 100644 --- a/resources/views/email.blade.php +++ b/resources/views/email.blade.php @@ -1,9 +1,9 @@ - +
-