moved logo method to view composer
This commit is contained in:
@ -107,17 +107,9 @@ class Invoices extends Controller
|
||||
|
||||
$categories = Category::enabled()->type('income')->pluck('name', 'id');
|
||||
|
||||
$recurrings = [
|
||||
'0' => trans('general.no'),
|
||||
'1' => trans('recurring.weekly'),
|
||||
'2' => trans('recurring.monthly'),
|
||||
'3' => trans('recurring.yearly'),
|
||||
'4' => trans('recurring.custom'),
|
||||
];
|
||||
|
||||
$number = $this->getNextInvoiceNumber();
|
||||
|
||||
return view('incomes.invoices.create', compact('customers', 'currencies', 'items', 'taxes', 'categories', 'recurrings', 'number'));
|
||||
return view('incomes.invoices.create', compact('customers', 'currencies', 'items', 'taxes', 'categories', 'number'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,9 +546,7 @@ class Invoices extends Controller
|
||||
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
$logo = $this->getLogo();
|
||||
|
||||
$html = view($invoice->template_path, compact('invoice', 'logo'))->render();
|
||||
$html = view($invoice->template_path, compact('invoice'))->render();
|
||||
|
||||
$pdf = \App::make('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
@ -610,9 +600,7 @@ class Invoices extends Controller
|
||||
{
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
$logo = $this->getLogo();
|
||||
|
||||
return view($invoice->template_path, compact('invoice', 'logo'));
|
||||
return view($invoice->template_path, compact('invoice'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -626,9 +614,7 @@ class Invoices extends Controller
|
||||
{
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
$logo = $this->getLogo();
|
||||
|
||||
$html = view($invoice->template_path, compact('invoice', 'logo'))->render();
|
||||
$html = view($invoice->template_path, compact('invoice'))->render();
|
||||
|
||||
$pdf = \App::make('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
@ -877,39 +863,4 @@ class Invoices extends Controller
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getLogo()
|
||||
{
|
||||
$logo = '';
|
||||
|
||||
$media_id = setting('general.company_logo');
|
||||
|
||||
if (setting('general.invoice_logo')) {
|
||||
$media_id = setting('general.invoice_logo');
|
||||
}
|
||||
|
||||
$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