Merge pull request #1413 from denisdulici/master
Added invoice/bill number to pdf filename
This commit is contained in:
commit
84631d1f80
@ -343,7 +343,7 @@ class Bills extends Controller
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
$file_name = 'bill_' . time() . '.pdf';
|
||||
$file_name = $this->getBillFileName($bill);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
@ -332,7 +332,9 @@ class Invoices extends Controller
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
$file = storage_path('app/temp/invoice_'.time().'.pdf');
|
||||
$file_name = $this->getInvoiceFileName($invoice);
|
||||
|
||||
$file = storage_path('app/temp/' . $file_name);
|
||||
|
||||
$invoice->pdf_path = $file;
|
||||
|
||||
@ -394,7 +396,7 @@ class Invoices extends Controller
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$file_name = 'invoice_'.time().'.pdf';
|
||||
$file_name = $this->getInvoiceFileName($invoice);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait Purchases
|
||||
{
|
||||
/**
|
||||
@ -58,4 +60,14 @@ trait Purchases
|
||||
|
||||
return $statuses;
|
||||
}
|
||||
|
||||
public function getBillFileName($bill, $separator = '-', $extension = 'pdf')
|
||||
{
|
||||
return $this->getSafeBillNumber($bill, $separator) . $separator . time() . '.' . $extension;
|
||||
}
|
||||
|
||||
public function getSafeBillNumber($bill, $separator = '-')
|
||||
{
|
||||
return Str::slug($bill->bill_number, $separator, language()->getShortCode());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait Sales
|
||||
{
|
||||
/**
|
||||
@ -60,4 +62,14 @@ trait Sales
|
||||
|
||||
return $statuses;
|
||||
}
|
||||
|
||||
public function getInvoiceFileName($invoice, $separator = '-', $extension = 'pdf')
|
||||
{
|
||||
return $this->getSafeInvoiceNumber($invoice, $separator) . $separator . time() . '.' . $extension;
|
||||
}
|
||||
|
||||
public function getSafeInvoiceNumber($invoice, $separator = '-')
|
||||
{
|
||||
return Str::slug($invoice->invoice_number, $separator, language()->getShortCode());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user