Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- add English email template from contact form #385

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/DTOs/ContactFormResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions app/Http/Requests/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function data(): array
"email" => $this->get("email"),
"topic" => $this->get("topic"),
"message" => $this->get("message"),
"lang" => app()->getLocale(),
];
}
}
3 changes: 2 additions & 1 deletion app/Mail/ContactFormResponded.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
2 changes: 2 additions & 0 deletions app/Models/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @property string $email
* @property string $topic
* @property string $message
* @property string $lang
* @property ContactFormStatus $status
*/
class ContactForm extends Model
Expand All @@ -24,6 +25,7 @@ class ContactForm extends Model
"message",
"status",
"response",
"lang",
];
protected $casts = [
"status" => ContactFormStatus::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up(): void
{
Schema::table("contact_forms", function (Blueprint $table): void {
$table->string("lang")->default("pl");
});
}

public function down(): void
{
Schema::table("contact_forms", function (Blueprint $table): void {
$table->dropColumn("lang");
});
}
};
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions lang/en/email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return [
"subject" => "Response to contact form",
"header" => "Response from contact form",
"your_message" => "Your message",
"response" => "Response",
];
10 changes: 10 additions & 0 deletions lang/pl/email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return [
"subject" => "Odpowiedź na formularz kontaktowy",
"header" => "Odpowiedź z formularza kontaktowego",
"your_message" => "Twoja wiadomość",
"response" => "Odpowiedź",
];
10 changes: 5 additions & 5 deletions resources/views/email.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!doctype html>
<html lang="pl">
<html lang="{{ app()->getLocale() }}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Odpowiedź na formularz kontaktowy</title>
<title>{{ __('email.subject') }}</title>
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
Expand Down Expand Up @@ -157,17 +157,17 @@
<tr>
<td class="container">
<div class="content">
<h1>Odpowiedź z formularza kontaktowego</h1>
<h1>{{ __('email.header') }}</h1>
<table role="presentation" style="width: 100%;" class="main">
<tr>
<td class="wrapper">
<div class="message">
<h3>Twoja wiadomość</h3>
<h3>{{ __('email.your_message') }}</h3>
<div class="message-box">
<p>{!! $details->messageDescription !!}</p>
</div>
</div>
<h3>Odpowiedź</h3>
<h3>{{ __('email.response') }}</h3>
<div class="response-box">
{!! $details->response !!}
</div>
Expand Down
Loading