diff --git a/app/Models/Account.php b/app/Models/Account.php index bf57ab820fbc..b10aa597ae43 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -320,7 +320,7 @@ class Account extends Eloquent public function hasLogo() { - return file_exists($this->getLogoPath()); + return file_exists($this->getLogoFullPath()); } public function getLogoPath() @@ -330,6 +330,13 @@ class Account extends Eloquent return file_exists($fileName.'.png') ? $fileName.'.png' : $fileName.'.jpg'; } + public function getLogoFullPath() + { + $fileName = public_path() . '/logo/' . $this->account_key; + + return file_exists($fileName.'.png') ? $fileName.'.png' : $fileName.'.jpg'; + } + public function getLogoURL() { return SITE_URL . '/' . $this->getLogoPath(); @@ -348,7 +355,7 @@ class Account extends Eloquent public function getLogoWidth() { - $path = $this->getLogoPath(); + $path = $this->getLogoFullPath(); if (!file_exists($path)) { return 0; } @@ -359,7 +366,7 @@ class Account extends Eloquent public function getLogoHeight() { - $path = $this->getLogoPath(); + $path = $this->getLogoFullPath(); if (!file_exists($path)) { return 0; } @@ -656,7 +663,7 @@ class Account extends Eloquent return 0; } - $filename = $this->getLogoPath(); + $filename = $this->getLogoFullPath(); return round(File::size($filename) / 1000); } diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 4448ea208716..1fd6c7117dcc 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -385,7 +385,7 @@ class AccountRepository $item->account_id = $user->account->id; $item->account_name = $user->account->getDisplayName(); $item->pro_plan_paid = $user->account->pro_plan_paid; - $item->logo_path = file_exists($user->account->getLogoPath()) ? $user->account->getLogoPath() : null; + $item->logo_path = $user->account->hasLogo() ? $user->account->getLogoPath() : null; $data[] = $item; } diff --git a/resources/views/emails/partials/account_logo.blade.php b/resources/views/emails/partials/account_logo.blade.php index c16e142fd5c1..cfe158153fe7 100644 --- a/resources/views/emails/partials/account_logo.blade.php +++ b/resources/views/emails/partials/account_logo.blade.php @@ -3,7 +3,7 @@ @endif - + @if ($account->website) diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 23c8a9d5fa28..81ff68aa94fb 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -934,7 +934,7 @@ } @endif - @if (file_exists($account->getLogoPath())) + @if ($account->hasLogo()) invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}"; invoice.imageWidth = {{ $account->getLogoWidth() }}; invoice.imageHeight = {{ $account->getLogoHeight() }}; diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index 8ca82c740065..eba6f4453187 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -62,7 +62,7 @@ logoImages.imageLogoWidth3 =325/2; logoImages.imageLogoHeight3 = 81/2; - @if (file_exists($account->getLogoPath())) + @if ($account->hasLogo()) window.accountLogo = "{{ HTML::image_data($account->getLogoPath()) }}"; if (window.invoice) { invoice.image = window.accountLogo;