From 4f3ab05757034ff3ea67be577f42c023b8969204 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 9 Feb 2026 09:37:49 +0100 Subject: [PATCH] fix: use absolute URL for logo in all mail templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The logo ``src`` was ``/storage/photos/shares/logo.png`` — a relative path to a file that doesn't exist. Email clients cannot resolve relative URLs. Replaces with the absolute URL to the actual logo at ``https://boutique.jardinenvie.com/img/logo.png`` across all 4 mail templates. --- ..._070000_fix_logo_url_in_mail_templates.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 database/migrations/shop/2026_02_09_070000_fix_logo_url_in_mail_templates.php diff --git a/database/migrations/shop/2026_02_09_070000_fix_logo_url_in_mail_templates.php b/database/migrations/shop/2026_02_09_070000_fix_logo_url_in_mail_templates.php new file mode 100644 index 00000000..3d8d1b03 --- /dev/null +++ b/database/migrations/shop/2026_02_09_070000_fix_logo_url_in_mail_templates.php @@ -0,0 +1,56 @@ +replaceLogoInAllTemplates($this->oldSrc, $this->newSrc); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $this->replaceLogoInAllTemplates($this->newSrc, $this->oldSrc); + } + + private function replaceLogoInAllTemplates(string $from, string $to): void + { + $templates = DB::table('mail_templates')->get(); + + foreach ($templates as $template) { + $translations = json_decode($template->html_template, true); + + if (! $translations) { + continue; + } + + $changed = false; + + foreach ($translations as $lang => $html) { + $updated = str_replace($from, $to, $html); + if ($updated !== $html) { + $translations[$lang] = $updated; + $changed = true; + } + } + + if ($changed) { + DB::table('mail_templates') + ->where('id', $template->id) + ->update(['html_template' => json_encode($translations, JSON_UNESCAPED_UNICODE)]); + } + } + } +};