This commit is contained in:
Hillel Coren 2016-01-18 16:09:06 +02:00
parent e4784035fe
commit 86f1e13c87
5 changed files with 15 additions and 8 deletions

View File

@ -320,7 +320,7 @@ class Account extends Eloquent
public function hasLogo() public function hasLogo()
{ {
return file_exists($this->getLogoPath()); return file_exists($this->getLogoFullPath());
} }
public function getLogoPath() public function getLogoPath()
@ -330,6 +330,13 @@ class Account extends Eloquent
return file_exists($fileName.'.png') ? $fileName.'.png' : $fileName.'.jpg'; 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() public function getLogoURL()
{ {
return SITE_URL . '/' . $this->getLogoPath(); return SITE_URL . '/' . $this->getLogoPath();
@ -348,7 +355,7 @@ class Account extends Eloquent
public function getLogoWidth() public function getLogoWidth()
{ {
$path = $this->getLogoPath(); $path = $this->getLogoFullPath();
if (!file_exists($path)) { if (!file_exists($path)) {
return 0; return 0;
} }
@ -359,7 +366,7 @@ class Account extends Eloquent
public function getLogoHeight() public function getLogoHeight()
{ {
$path = $this->getLogoPath(); $path = $this->getLogoFullPath();
if (!file_exists($path)) { if (!file_exists($path)) {
return 0; return 0;
} }
@ -656,7 +663,7 @@ class Account extends Eloquent
return 0; return 0;
} }
$filename = $this->getLogoPath(); $filename = $this->getLogoFullPath();
return round(File::size($filename) / 1000); return round(File::size($filename) / 1000);
} }

View File

@ -385,7 +385,7 @@ class AccountRepository
$item->account_id = $user->account->id; $item->account_id = $user->account->id;
$item->account_name = $user->account->getDisplayName(); $item->account_name = $user->account->getDisplayName();
$item->pro_plan_paid = $user->account->pro_plan_paid; $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; $data[] = $item;
} }

View File

@ -3,7 +3,7 @@
<a href="{{ $account->website }}" style="color: #19BB40; text-decoration: underline;"> <a href="{{ $account->website }}" style="color: #19BB40; text-decoration: underline;">
@endif @endif
<img src="{{ $message->embed($account->getLogoPath()) }}" style="max-height:50px; max-width:140px; margin-left: 33px;" /> <img src="{{ $message->embed($account->getLogoFullPath()) }}" style="max-height:50px; max-width:140px; margin-left: 33px;" />
@if ($account->website) @if ($account->website)
</a> </a>

View File

@ -934,7 +934,7 @@
} }
@endif @endif
@if (file_exists($account->getLogoPath())) @if ($account->hasLogo())
invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}"; invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}";
invoice.imageWidth = {{ $account->getLogoWidth() }}; invoice.imageWidth = {{ $account->getLogoWidth() }};
invoice.imageHeight = {{ $account->getLogoHeight() }}; invoice.imageHeight = {{ $account->getLogoHeight() }};

View File

@ -62,7 +62,7 @@
logoImages.imageLogoWidth3 =325/2; logoImages.imageLogoWidth3 =325/2;
logoImages.imageLogoHeight3 = 81/2; logoImages.imageLogoHeight3 = 81/2;
@if (file_exists($account->getLogoPath())) @if ($account->hasLogo())
window.accountLogo = "{{ HTML::image_data($account->getLogoPath()) }}"; window.accountLogo = "{{ HTML::image_data($account->getLogoPath()) }}";
if (window.invoice) { if (window.invoice) {
invoice.image = window.accountLogo; invoice.image = window.accountLogo;