mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
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:
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user