Merge branch 'localhost-img-issue' into 'master'

fix localhost img display issue

See merge request mohit.panjvani/crater-web!638
This commit is contained in:
Mohit Panjwani
2020-12-08 12:15:57 +00:00
4 changed files with 32 additions and 4 deletions

View File

@ -430,7 +430,12 @@ class Estimate extends Model implements HasMedia
$company = Company::find($this->company_id);
$logo = $company->getMedia('logo')->first();
if ($logo) {
$isSystem = FileDisk::whereSetAsDefault(true)->first()->isSystem();
$isLocalhost = config('session.domain') === 'localhost';
if ($logo && $isLocalhost && $isSystem) {
$logo = $logo->getPath();
} else if($logo) {
$logo = $logo->getFullUrl();
}

View File

@ -8,6 +8,9 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
class FileDisk extends Model
{
CONST DISK_TYPE_SYSTEM = 'SYSTEM';
CONST DISK_TYPE_REMOTE = 'REMOTE';
use HasFactory;
protected $guarded = [
@ -184,4 +187,14 @@ class FileDisk extends Model
return $this;
}
public function isSystem()
{
return $this->type === self::DISK_TYPE_SYSTEM;
}
public function isRemote()
{
return $this->type === self::DISK_TYPE_REMOTE;
}
}

View File

@ -514,7 +514,12 @@ class Invoice extends Model implements HasMedia
$logo = $company->getMedia('logo')->first();
if ($logo) {
$isSystem = FileDisk::whereSetAsDefault(true)->first()->isSystem() ;
$isLocalhost = config('session.domain') === 'localhost';
if ($logo && $isLocalhost && $isSystem) {
$logo = $logo->getPath();
} else if($logo) {
$logo = $logo->getFullUrl();
}
@ -528,7 +533,6 @@ class Invoice extends Model implements HasMedia
'labels' => $labels,
'taxes' => $taxes
]);
return PDF::loadView('app.pdf.invoice.' . $invoiceTemplate->view);
}

View File

@ -375,10 +375,16 @@ class Payment extends Model implements HasMedia
$logo = $company->getMedia('logo')->first();
if ($logo) {
$isSystem = FileDisk::whereSetAsDefault(true)->first()->isSystem() ;
$isLocalhost = config('session.domain') === 'localhost';
if ($logo && $isLocalhost && $isSystem) {
$logo = $logo->getPath();
} else if($logo) {
$logo = $logo->getFullUrl();
}
view()->share([
'payment' => $this,
'company_address' => $this->getCompanyAddress(),