From d30842561628c34eb14916d98c83e6940a7fa31a Mon Sep 17 00:00:00 2001 From: guillaume91 Date: Fri, 14 Jun 2024 12:37:46 +0200 Subject: [PATCH] [fix] Mail Preview fixed. --- .../app/Livewire/Projects/Tabs/Mailings.php | 20 +++++++++++++++++-- .../livewire/projects/tabs/mailings.blade.php | 19 ++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/laravel_app/app/Livewire/Projects/Tabs/Mailings.php b/laravel_app/app/Livewire/Projects/Tabs/Mailings.php index a366f7f..7aed0e6 100644 --- a/laravel_app/app/Livewire/Projects/Tabs/Mailings.php +++ b/laravel_app/app/Livewire/Projects/Tabs/Mailings.php @@ -36,6 +36,7 @@ public function mount(Project $project) public function showMailingDetailsModal(ProjectMailing $mailing) { + $this->formData = $mailing->toArray(); $this->formData['attachments'] = $mailing->attachments->toArray(); @@ -81,8 +82,23 @@ public function render() ]); } - public function getMailPreview($mail) + public function getMailPreview($formData):? string { - return new ReportMailer($mail); + if(array_key_exists('id',$formData)){ + try { + return (new ReportMailer(ProjectMailing::find($formData['id'])))->render(); + } catch (\ReflectionException $e) { + logger('No Idea what "ReflectionException" means... but got triggered.'); + } + } + return null; + } + + public function getPreviewRoute($formData):?string + { + if(array_key_exists('id',$formData)){ + return route('mail',[$formData['id']]); + } + return null; } } diff --git a/laravel_app/resources/views/livewire/projects/tabs/mailings.blade.php b/laravel_app/resources/views/livewire/projects/tabs/mailings.blade.php index 2febf65..3270f3d 100644 --- a/laravel_app/resources/views/livewire/projects/tabs/mailings.blade.php +++ b/laravel_app/resources/views/livewire/projects/tabs/mailings.blade.php @@ -47,7 +47,7 @@ class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachm {{ $mail->recipients()->count() }} {{ $mail->attachments()->pluck('name')->join( ', ') }} - @@ -88,10 +88,17 @@ class="text-indigo-600 hover:text-indigo-900">Show @endforeach +
-
- {!! $this->getMailPreview($mail)->render() !!} +
+ {!! $this->getMailPreview($formData) !!} + +
@empty($formData['attachments']) @@ -101,9 +108,9 @@ class="text-indigo-600 hover:text-indigo-900">Show value="{{ __('No attachments where send with this message.') }}"/>
@else -
+
@foreach($formData['attachments'] as $key => $attachment) -
+
{{ $attachment['name'] }}
@@ -120,7 +127,7 @@ class="text-indigo-600 hover:text-indigo-900">Show
- + full page preview