fix company logo issue

This commit is contained in:
Mohit Panjwani
2021-01-22 19:00:37 +05:30
parent b7370ed85c
commit 7b95ccb5fc
4 changed files with 23 additions and 10 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Crater\Models; namespace Crater\Models;
use Crater\Models\Address; use Crater\Models\Address;
@ -17,9 +18,9 @@ class Company extends Model implements HasMedia
protected $fillable = ['name', 'logo', 'unique_hash']; protected $fillable = ['name', 'logo', 'unique_hash'];
protected $appends=['logo']; protected $appends = ['logo', 'logo_path'];
public function getLogoAttribute() public function getLogoPathAttribute()
{ {
$logo = $this->getMedia('logo')->first(); $logo = $this->getMedia('logo')->first();
@ -28,10 +29,22 @@ class Company extends Model implements HasMedia
if ($logo) { if ($logo) {
if ($isSystem) { if ($isSystem) {
return $logo->getPath(); return $logo->getPath();
} else { } else {
return $logo->getFullUrl(); return $logo->getFullUrl();
} }
} }
return null;
}
public function getLogoAttribute()
{
$logo = $this->getMedia('logo')->first();
if ($logo) {
return $logo->getFullUrl();
}
return null; return null;
} }

View File

@ -426,7 +426,7 @@ class Estimate extends Model implements HasMedia
$estimateTemplate = EstimateTemplate::find($this->estimate_template_id); $estimateTemplate = EstimateTemplate::find($this->estimate_template_id);
$company = Company::find($this->company_id); $company = Company::find($this->company_id);
$logo = $company->logo; $logo = $company->logo_path;
view()->share([ view()->share([
'estimate' => $this, 'estimate' => $this,

View File

@ -510,7 +510,7 @@ class Invoice extends Model implements HasMedia
$company = Company::find($this->company_id); $company = Company::find($this->company_id);
$logo = $company->logo; $logo = $company->logo_path;
view()->share([ view()->share([
'invoice' => $this, 'invoice' => $this,

View File

@ -216,10 +216,10 @@ class Payment extends Model implements HasMedia
} }
$payment = Payment::with([ $payment = Payment::with([
'user', 'user',
'invoice', 'invoice',
'paymentMethod', 'paymentMethod',
]) ])
->find($this->id); ->find($this->id);
return $payment; return $payment;
@ -373,7 +373,7 @@ class Payment extends Model implements HasMedia
{ {
$company = Company::find($this->company_id); $company = Company::find($this->company_id);
$logo = $company->logo; $logo = $company->logo_path;
view()->share([ view()->share([
'payment' => $this, 'payment' => $this,