From c386167762f38dbd034cde290d00f9a7aa14ea26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Wed, 19 Aug 2020 16:35:54 +0200 Subject: [PATCH] Add company setting for enabling client portal uploads --- app/DataMapper/CompanySettings.php | 2 ++ .../Requests/ClientPortal/Uploads/StoreUploadRequest.php | 3 +-- .../ninja2020/components/livewire/downloads-table.blade.php | 2 +- resources/views/portal/ninja2020/downloads/index.blade.php | 5 ++++- resources/views/portal/ninja2020/upload/index.blade.php | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index a968cbc5b2ed..264d6d5eb96b 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -235,6 +235,7 @@ class CompanySettings extends BaseSettings public $client_can_register = false; public $client_portal_terms = ''; public $client_portal_privacy_policy = ''; + public $client_portal_enable_uploads = false; public static $casts = [ 'lock_invoices' => 'string', @@ -402,6 +403,7 @@ class CompanySettings extends BaseSettings 'portal_custom_css' => 'string', 'portal_custom_footer' => 'string', 'portal_custom_js' => 'string', + 'client_portal_enable_uploads' => 'bool', ]; diff --git a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php index 2bd940c0dbed..f3432b0989a4 100644 --- a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php +++ b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php @@ -13,8 +13,7 @@ class StoreUploadRequest extends FormRequest */ public function authorize() { - // TODO: Check for the setting to allow client uploads. - return true; + return (bool) auth('contact')->user()->client->getSetting('client_portal_enable_uploads'); } /** diff --git a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php index 64321bfbefb2..bc99dacc442e 100644 --- a/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/downloads-table.blade.php @@ -1,4 +1,4 @@ -
+
diff --git a/resources/views/portal/ninja2020/downloads/index.blade.php b/resources/views/portal/ninja2020/downloads/index.blade.php index a6e73e06dd85..12825cde2af9 100644 --- a/resources/views/portal/ninja2020/downloads/index.blade.php +++ b/resources/views/portal/ninja2020/downloads/index.blade.php @@ -2,7 +2,10 @@ @section('meta_title', ctrans('texts.downloads')) @section('header') - @component('portal.ninja2020.upload.index')@endcomponent + {{ dd(auth('contact')->user()->client) }} + @if($client->getSetting('client_portal_enable_uploads')) + @component('portal.ninja2020.upload.index') @endcomponent + @endif @endsection @section('body') diff --git a/resources/views/portal/ninja2020/upload/index.blade.php b/resources/views/portal/ninja2020/upload/index.blade.php index 346c13cf8d80..5a3543b54db5 100644 --- a/resources/views/portal/ninja2020/upload/index.blade.php +++ b/resources/views/portal/ninja2020/upload/index.blade.php @@ -1,7 +1,7 @@ -
+
{{ ctrans('texts.allowed_file_types' )}} png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx
@csrf