From 161f20fae75329bc4da2b7f9134055f02844d1c8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Apr 2021 22:36:50 +1000 Subject: [PATCH] Fixes for paths to s3 type storage --- app/Http/Controllers/InvoiceController.php | 2 -- app/Models/Company.php | 1 - app/Services/Credit/GetCreditPdf.php | 4 ++++ app/Services/Quote/GetQuotePdf.php | 4 ++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 8451e1d7a3e5..3379ecf4a763 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -795,8 +795,6 @@ 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/Company.php b/app/Models/Company.php index 73f2d1e8c954..eeff9efe43c4 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -100,7 +100,6 @@ class Company extends BaseModel 'country_id' => 'string', 'custom_fields' => 'object', 'settings' => 'object', - 'custom_fields' => 'object', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', diff --git a/app/Services/Credit/GetCreditPdf.php b/app/Services/Credit/GetCreditPdf.php index 96bb0f818e7d..84deac828d5f 100644 --- a/app/Services/Credit/GetCreditPdf.php +++ b/app/Services/Credit/GetCreditPdf.php @@ -13,6 +13,7 @@ namespace App\Services\Credit; use App\Jobs\Entity\CreateEntityPdf; use App\Services\AbstractService; +use App\Utils\TempFile; use Illuminate\Support\Facades\Storage; class GetCreditPdf extends AbstractService @@ -48,6 +49,9 @@ class GetCreditPdf extends AbstractService $file_path = CreateEntityPdf::dispatchNow($this->invitation); } + if(config('filesystems.default') == 's3') + return TempFile::path(Storage::disk($disk)->url($file_path)); + return Storage::disk($disk)->path($file_path); } } diff --git a/app/Services/Quote/GetQuotePdf.php b/app/Services/Quote/GetQuotePdf.php index 582664aaacd1..2d8b62539c66 100644 --- a/app/Services/Quote/GetQuotePdf.php +++ b/app/Services/Quote/GetQuotePdf.php @@ -15,6 +15,7 @@ use App\Jobs\Entity\CreateEntityPdf; use App\Models\ClientContact; use App\Models\Quote; use App\Services\AbstractService; +use App\Utils\TempFile; use Illuminate\Support\Facades\Storage; class GetQuotePdf extends AbstractService @@ -46,6 +47,9 @@ class GetQuotePdf extends AbstractService $file_path = CreateEntityPdf::dispatchNow($invitation); } + if(config('filesystems.default') == 's3') + return TempFile::path(Storage::disk($disk)->url($file_path)); + return Storage::disk($disk)->path($file_path); } }