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.');