From 89598d44ef8fb5eaf7977c9c3d68288e0fd590e1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 24 Mar 2021 09:28:42 +1100 Subject: [PATCH] Fixes for naming PDFs --- app/Http/Controllers/InvoiceController.php | 2 ++ app/Models/BaseModel.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index b9e99002f4..9c037e9228 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -795,6 +795,8 @@ class InvoiceController extends BaseController $file_path = $invoice->service()->getInvoicePdf($contact); +nlog($file_path); + return response()->download($file_path, basename($file_path)); } diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 8d818643d6..ab0e0ee4b8 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -191,7 +191,9 @@ class BaseModel extends Model public function numberFormatter() { - $formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $this->number); + $number = strlen($this->number) > 1 ? $this->number : class_basename($this); + + $formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $number); // Remove any runs of periods (thanks falstro!) $formatted_number = mb_ereg_replace("([\.]{2,})", '', $formatted_number);