diff --git a/app/Models/Document.php b/app/Models/Document.php index 0a94074ff4e2..9d570882d267 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -234,6 +234,23 @@ class Document extends EntityModel return $disk->get($this->path); } + /** + * @return mixed + */ + public function getRawCached() + { + $key = 'image:' . $this->path; + + if ($image = cache($key)) { + // do nothing + } else { + $image = $this->getRaw(); + cache([$key => $image], 120); + } + + return $image; + } + /** * @return mixed */ diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index ce06c9939ecb..438e34f36d20 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -89,7 +89,7 @@ @endif @if ($account->isEnterprise() && $account->background_image_id && $account->background_image) - window.accountBackground = "{{ Form::image_data($account->background_image->getRaw(), true) }}"; + window.accountBackground = "{{ Form::image_data($account->background_image->getRawCached(), true) }}"; @endif var NINJA = NINJA || {};