close #2061 Fixed: Not showing company logo in invoice/bill page

This commit is contained in:
Cüneyt Şentürk 2021-05-26 16:10:04 +03:00
parent f0f4e99bc2
commit db966860f1
3 changed files with 21 additions and 9 deletions

View File

@ -596,7 +596,7 @@ abstract class DocumentShow extends Base
if (!empty($media)) { if (!empty($media)) {
$path = Storage::path($media->getDiskPath()); $path = Storage::path($media->getDiskPath());
if (!is_file($path)) { if (!Storage::exists($path)) {
return $logo; return $logo;
} }
} else { } else {
@ -604,11 +604,15 @@ abstract class DocumentShow extends Base
} }
try { try {
$image = Image::cache(function($image) use ($path) { $image = Image::cache(function($image) use ($media, $path) {
$width = setting('invoice.logo_size_width'); $width = setting('invoice.logo_size_width');
$height = setting('invoice.logo_size_height'); $height = setting('invoice.logo_size_height');
if ($media) {
$image->make($media->stream())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode(); $image->make($path)->resize($width, $height)->encode();
}
}); });
} catch (NotReadableException | \Exception $e) { } catch (NotReadableException | \Exception $e) {
Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.'); Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.');

View File

@ -198,7 +198,7 @@ abstract class DocumentTemplate extends Base
if (!empty($media)) { if (!empty($media)) {
$path = Storage::path($media->getDiskPath()); $path = Storage::path($media->getDiskPath());
if (!is_file($path)) { if (!Storage::exists($path)) {
return $logo; return $logo;
} }
} else { } else {
@ -206,11 +206,15 @@ abstract class DocumentTemplate extends Base
} }
try { try {
$image = Image::cache(function($image) use ($path) { $image = Image::cache(function($image) use ($media, $path) {
$width = setting('invoice.logo_size_width'); $width = setting('invoice.logo_size_width');
$height = setting('invoice.logo_size_height'); $height = setting('invoice.logo_size_height');
if ($media) {
$image->make($media->stream())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode(); $image->make($path)->resize($width, $height)->encode();
}
}); });
} catch (NotReadableException | \Exception $e) { } catch (NotReadableException | \Exception $e) {
Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.'); Log::info('Company ID: ' . company_id() . ' components/documentshow.php exception.');

View File

@ -27,7 +27,7 @@ class Logo
if (!empty($media)) { if (!empty($media)) {
$path = Storage::path($media->getDiskPath()); $path = Storage::path($media->getDiskPath());
if (!is_file($path)) { if (!Storage::exists($path)) {
return $logo; return $logo;
} }
} else { } else {
@ -35,11 +35,15 @@ class Logo
} }
try { try {
$image = Image::cache(function($image) use ($path) { $image = Image::cache(function($image) use ($media, $path) {
$width = setting('invoice.logo_size_width'); $width = setting('invoice.logo_size_width');
$height = setting('invoice.logo_size_height'); $height = setting('invoice.logo_size_height');
if ($media) {
$image->make($media->stream())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode(); $image->make($path)->resize($width, $height)->encode();
}
}); });
} catch (NotReadableException | \Exception $e) { } catch (NotReadableException | \Exception $e) {
Log::info('Company ID: ' . company_id() . ' viewcomposer/logo.php exception.'); Log::info('Company ID: ' . company_id() . ' viewcomposer/logo.php exception.');