moved logo method to view composer
This commit is contained in:
@ -511,9 +511,7 @@ class Bills extends Controller
|
||||
{
|
||||
$bill = $this->prepareBill($bill);
|
||||
|
||||
$logo = $this->getLogo($bill);
|
||||
|
||||
return view($bill->template_path, compact('bill', 'logo'));
|
||||
return view($bill->template_path, compact('bill'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -527,9 +525,7 @@ class Bills extends Controller
|
||||
{
|
||||
$bill = $this->prepareBill($bill);
|
||||
|
||||
$logo = $this->getLogo($bill);
|
||||
|
||||
$html = view($bill->template_path, compact('bill', 'logo'))->render();
|
||||
$html = view($bill->template_path, compact('bill'))->render();
|
||||
|
||||
$pdf = \App::make('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
@ -736,39 +732,4 @@ class Bills extends Controller
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getLogo($bill)
|
||||
{
|
||||
$logo = '';
|
||||
|
||||
$media_id = setting('general.company_logo');
|
||||
|
||||
if (isset($bill->vendor->logo) && !empty($bill->vendor->logo->id)) {
|
||||
$media_id = $bill->vendor->logo->id;
|
||||
}
|
||||
|
||||
$media = Media::find($media_id);
|
||||
|
||||
if (!empty($media)) {
|
||||
$path = Storage::path($media->getDiskPath());
|
||||
|
||||
if (!is_file($path)) {
|
||||
return $logo;
|
||||
}
|
||||
} else {
|
||||
$path = asset('public/img/company.png');
|
||||
}
|
||||
|
||||
$image = Image::make($path)->encode()->getEncoded();
|
||||
|
||||
if (empty($image)) {
|
||||
return $logo;
|
||||
}
|
||||
|
||||
$extension = File::extension($path);
|
||||
|
||||
$logo = 'data:image/' . $extension . ';base64,' . base64_encode($image);
|
||||
|
||||
return $logo;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user