From a502cee73ef9d8825f041cdec7bcaf6cd9c76fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 17 Jun 2021 14:43:14 +0200 Subject: [PATCH] Enabled modules for InvoiceController.php --- .../ClientPortal/InvoiceController.php | 7 +++-- .../Invoices/ProcessInvoicesInBulkRequest.php | 31 +++++++++++++++++++ .../{ => Invoices}/ShowInvoiceRequest.php | 6 ++-- .../Invoices/ShowInvoicesRequest.php | 31 +++++++++++++++++++ .../ProcessInvoicesInBulkRequest.php | 30 ------------------ 5 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php rename app/Http/Requests/ClientPortal/{ => Invoices}/ShowInvoiceRequest.php (73%) create mode 100644 app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php delete mode 100644 app/Http/Requests/ClientPortal/ProcessInvoicesInBulkRequest.php diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 48ec01b898..804e4cd91a 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -12,8 +12,9 @@ namespace App\Http\Controllers\ClientPortal; use App\Http\Controllers\Controller; -use App\Http\Requests\ClientPortal\ProcessInvoicesInBulkRequest; -use App\Http\Requests\ClientPortal\ShowInvoiceRequest; +use App\Http\Requests\ClientPortal\Invoices\ShowInvoicesRequest; +use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest; +use App\Http\Requests\ClientPortal\Invoices\ShowInvoiceRequest; use App\Models\Invoice; use App\Utils\Number; use App\Utils\TempFile; @@ -33,7 +34,7 @@ class InvoiceController extends Controller * * @return Factory|View */ - public function index() + public function index(ShowInvoicesRequest $request) { return $this->render('invoices.index'); } diff --git a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php new file mode 100644 index 0000000000..512874a380 --- /dev/null +++ b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php @@ -0,0 +1,31 @@ +user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; + } + + public function rules() + { + return [ + 'invoices' => ['array'], + ]; + } +} diff --git a/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php similarity index 73% rename from app/Http/Requests/ClientPortal/ShowInvoiceRequest.php rename to app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php index 3ecae80465..f272521d08 100644 --- a/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php @@ -9,9 +9,10 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace App\Http\Requests\ClientPortal; +namespace App\Http\Requests\ClientPortal\Invoices; use App\Http\Requests\Request; +use App\Http\ViewComposers\PortalComposer; class ShowInvoiceRequest extends Request { @@ -22,6 +23,7 @@ class ShowInvoiceRequest extends Request */ public function authorize() : bool { - return auth('contact')->user()->client->id == $this->invoice->client_id; + return auth('contact')->user()->client->id == $this->invoice->client_id + && auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } } diff --git a/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php new file mode 100644 index 0000000000..8a815d9554 --- /dev/null +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php @@ -0,0 +1,31 @@ +user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; + } + + public function rules() + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/ClientPortal/ProcessInvoicesInBulkRequest.php b/app/Http/Requests/ClientPortal/ProcessInvoicesInBulkRequest.php deleted file mode 100644 index 9a41f91069..0000000000 --- a/app/Http/Requests/ClientPortal/ProcessInvoicesInBulkRequest.php +++ /dev/null @@ -1,30 +0,0 @@ - ['array'], - ]; - } -}