From f35ad6a5a35fd3135d399a683955888fc6db1fe5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 27 Sep 2021 08:03:11 +1000 Subject: [PATCH] Inline downloads for file resources --- app/Filters/DocumentFilters.php | 8 ++++---- .../Controllers/ClientPortal/DocumentController.php | 7 ++++++- app/Models/GatewayType.php | 11 ----------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/Filters/DocumentFilters.php b/app/Filters/DocumentFilters.php index 125416d19d..50731fc7df 100644 --- a/app/Filters/DocumentFilters.php +++ b/app/Filters/DocumentFilters.php @@ -20,10 +20,10 @@ use Illuminate\Database\Eloquent\Builder; class DocumentFilters extends QueryFilters { - public function client_id(int $client_id) :Builder - { - return $this->builder->where('client_id', $client_id); - } + // public function client_id(int $client_id) :Builder + // { + // return $this->builder->where('client_id', $client_id); + // } /** * Filter based on search text. diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index f58001ac35..54d25ea99d 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -57,7 +57,12 @@ class DocumentController extends Controller { $document = Document::where('hash', $document_hash)->firstOrFail(); - return Storage::disk($document->disk)->download($document->url, $document->name); + $headers = []; + + if(request()->input('inline') == 'true') + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + + return Storage::disk($document->disk)->download($document->url, $document->name, $headers); } public function downloadMultiple(DownloadMultipleDocumentsRequest $request) diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index 6435db19b0..a7e06fb64c 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -43,37 +43,26 @@ class GatewayType extends StaticModel switch ($type) { case self::CREDIT_CARD: return ctrans('texts.credit_card'); - break; case self::BANK_TRANSFER: return ctrans('texts.bank_transfer'); - break; case self::PAYPAL: return ctrans('texts.paypal'); - break; case self::CRYPTO: return ctrans('texts.crypto'); - break; case self::CUSTOM: return ctrans('texts.custom'); - break; case self::ALIPAY: return ctrans('texts.alipay'); - break; case self::SOFORT: return ctrans('texts.sofort'); - break; case self::APPLE_PAY: return ctrans('texts.apple_pay'); - break; case self::SEPA: return ctrans('texts.sepa'); - break; case self::KBC: return ctrans('texts.kbc_cbc'); - break; case self::BANCONTACT: return ctrans('texts.bancontact'); - break; default: return 'Undefined.';