Fixes for mailers

This commit is contained in:
David Bomba 2023-10-07 08:55:52 +11:00
parent 81098bb33f
commit 28909b6396
2 changed files with 3 additions and 2 deletions

View File

@ -96,6 +96,7 @@ class EmailMailable extends Mailable
$documents = Document::query()->whereIn('id', $this->email_object->documents) $documents = Document::query()->whereIn('id', $this->email_object->documents)
->where('size', '<', $this->max_attachment_size) ->where('size', '<', $this->max_attachment_size)
->where('is_public',1)
->cursor() ->cursor()
->map(function ($document) { ->map(function ($document) {
return Attachment::fromData(fn () => $document->getFile(), $document->name); return Attachment::fromData(fn () => $document->getFile(), $document->name);

View File

@ -4,7 +4,7 @@
<div class="sm:flex sm:items-start sm:justify-between"> <div class="sm:flex sm:items-start sm:justify-between">
<div> <div>
<p class="text-lg leading-6 font-medium text-gray-900">{{ ctrans('texts.attachments') }}:</p> <p class="text-lg leading-6 font-medium text-gray-900">{{ ctrans('texts.attachments') }}:</p>
@foreach ($entity->documents as $document) @foreach ($entity->documents()->where('is_public',1)->get() as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
@if($entity instanceof App\Models\PurchaseOrder) @if($entity instanceof App\Models\PurchaseOrder)
<a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank" <a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank"
@ -27,7 +27,7 @@
</div> </div>
@endforeach @endforeach
@foreach ($entity->company->documents as $document) @foreach ($entity->company->documents()->where('is_public',1)->get() as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
@if($entity instanceof App\Models\PurchaseOrder) @if($entity instanceof App\Models\PurchaseOrder)
<a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank" <a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank"