From db966860f1bcb75eb3a09e8cbfe5ea26c11e7149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 26 May 2021 16:10:04 +0300 Subject: [PATCH] close #2061 Fixed: Not showing company logo in invoice/bill page --- app/Abstracts/View/Components/DocumentShow.php | 10 +++++++--- app/Abstracts/View/Components/DocumentTemplate.php | 10 +++++++--- app/Http/ViewComposers/Logo.php | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index f0d313a26..a398927e1 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -596,7 +596,7 @@ abstract class DocumentShow extends Base if (!empty($media)) { $path = Storage::path($media->getDiskPath()); - if (!is_file($path)) { + if (!Storage::exists($path)) { return $logo; } } else { @@ -604,11 +604,15 @@ abstract class DocumentShow extends Base } try { - $image = Image::cache(function($image) use ($path) { + $image = Image::cache(function($image) use ($media, $path) { $width = setting('invoice.logo_size_width'); $height = setting('invoice.logo_size_height'); - $image->make($path)->resize($width, $height)->encode(); + if ($media) { + $image->make($media->stream())->resize($width, $height)->encode(); + } else { + $image->make($path)->resize($width, $height)->encode(); + } }); } catch (NotReadableException | \Exception $e) { Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.'); diff --git a/app/Abstracts/View/Components/DocumentTemplate.php b/app/Abstracts/View/Components/DocumentTemplate.php index add41f9da..00952f272 100644 --- a/app/Abstracts/View/Components/DocumentTemplate.php +++ b/app/Abstracts/View/Components/DocumentTemplate.php @@ -198,7 +198,7 @@ abstract class DocumentTemplate extends Base if (!empty($media)) { $path = Storage::path($media->getDiskPath()); - if (!is_file($path)) { + if (!Storage::exists($path)) { return $logo; } } else { @@ -206,11 +206,15 @@ abstract class DocumentTemplate extends Base } try { - $image = Image::cache(function($image) use ($path) { + $image = Image::cache(function($image) use ($media, $path) { $width = setting('invoice.logo_size_width'); $height = setting('invoice.logo_size_height'); - $image->make($path)->resize($width, $height)->encode(); + if ($media) { + $image->make($media->stream())->resize($width, $height)->encode(); + } else { + $image->make($path)->resize($width, $height)->encode(); + } }); } catch (NotReadableException | \Exception $e) { Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.'); diff --git a/app/Http/ViewComposers/Logo.php b/app/Http/ViewComposers/Logo.php index c72680de7..401c7b973 100644 --- a/app/Http/ViewComposers/Logo.php +++ b/app/Http/ViewComposers/Logo.php @@ -27,7 +27,7 @@ class Logo if (!empty($media)) { $path = Storage::path($media->getDiskPath()); - if (!is_file($path)) { + if (!Storage::exists($path)) { return $logo; } } else { @@ -35,11 +35,15 @@ class Logo } try { - $image = Image::cache(function($image) use ($path) { + $image = Image::cache(function($image) use ($media, $path) { $width = setting('invoice.logo_size_width'); $height = setting('invoice.logo_size_height'); - $image->make($path)->resize($width, $height)->encode(); + if ($media) { + $image->make($media->stream())->resize($width, $height)->encode(); + } else { + $image->make($path)->resize($width, $height)->encode(); + } }); } catch (NotReadableException | \Exception $e) { Log::info('Company ID: ' . company_id() . ' viewcomposer/logo.php exception.');