From e39ce7491b6dd966ae459e1a2625bc91982eb124 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 8 Mar 2021 08:32:38 +1100 Subject: [PATCH] Feature permissions for hosted --- app/Http/Controllers/ClientController.php | 4 ++++ app/Http/Controllers/CompanyController.php | 4 ++++ app/Http/Controllers/CreditController.php | 4 ++++ app/Http/Controllers/ExpenseController.php | 4 ++++ app/Http/Controllers/PaymentController.php | 4 ++++ app/Http/Controllers/ProductController.php | 4 ++++ app/Http/Controllers/ProjectController.php | 4 ++++ app/Http/Controllers/QuoteController.php | 4 ++++ app/Http/Controllers/RecurringInvoiceController.php | 4 ++++ app/Http/Controllers/TaskController.php | 6 +++++- app/Http/Controllers/VendorController.php | 4 ++++ 11 files changed, 45 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index c38aee312a..38b043510a 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -24,6 +24,7 @@ use App\Http\Requests\Client\UpdateClientRequest; use App\Http\Requests\Client\UploadClientRequest; use App\Jobs\Client\StoreClient; use App\Jobs\Client\UpdateClient; +use App\Models\Account; use App\Models\Client; use App\Repositories\ClientRepository; use App\Transformers\ClientTransformer; @@ -574,6 +575,9 @@ class ClientController extends BaseController public function upload(UploadClientRequest $request, Client $client) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $client); diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 9bfffe27f6..5e85366836 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -26,6 +26,7 @@ use App\Jobs\Company\CreateCompanyPaymentTerms; use App\Jobs\Company\CreateCompanyTaskStatuses; use App\Jobs\Company\CreateCompanyToken; use App\Jobs\Ninja\RefundCancelledAccount; +use App\Models\Account; use App\Models\Company; use App\Models\CompanyUser; use App\Repositories\CompanyRepository; @@ -559,6 +560,9 @@ class CompanyController extends BaseController public function upload(UploadCompanyRequest $request, Company $company) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $company); diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index efdec9af28..41a035074f 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -26,6 +26,7 @@ use App\Http\Requests\Credit\UpdateCreditRequest; use App\Http\Requests\Credit\UploadCreditRequest; use App\Jobs\Entity\EmailEntity; use App\Jobs\Invoice\EmailCredit; +use App\Models\Account; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; @@ -643,6 +644,9 @@ class CreditController extends BaseController public function upload(UploadCreditRequest $request, Credit $credit) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $credit); diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index 9b7b74939a..b1b5e9db9c 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -22,6 +22,7 @@ use App\Http\Requests\Expense\ShowExpenseRequest; use App\Http\Requests\Expense\StoreExpenseRequest; use App\Http\Requests\Expense\UpdateExpenseRequest; use App\Http\Requests\Expense\UploadExpenseRequest; +use App\Models\Account; use App\Models\Expense; use App\Repositories\ExpenseRepository; use App\Transformers\ExpenseTransformer; @@ -565,6 +566,9 @@ class ExpenseController extends BaseController public function upload(UploadExpenseRequest $request, Expense $expense) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $expense); diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 53bd526bd4..a4265f800f 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -23,6 +23,7 @@ use App\Http\Requests\Payment\ShowPaymentRequest; use App\Http\Requests\Payment\StorePaymentRequest; use App\Http\Requests\Payment\UpdatePaymentRequest; use App\Http\Requests\Payment\UploadPaymentRequest; +use App\Models\Account; use App\Models\Invoice; use App\Models\Payment; use App\Repositories\PaymentRepository; @@ -729,6 +730,9 @@ class PaymentController extends BaseController public function upload(UploadPaymentRequest $request, Payment $payment) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $payment); diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index aa7bca103a..83e818d57d 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -20,6 +20,7 @@ use App\Http\Requests\Product\ShowProductRequest; use App\Http\Requests\Product\StoreProductRequest; use App\Http\Requests\Product\UpdateProductRequest; use App\Http\Requests\Product\UploadProductRequest; +use App\Models\Account; use App\Models\Product; use App\Repositories\ProductRepository; use App\Transformers\ProductTransformer; @@ -534,6 +535,9 @@ class ProductController extends BaseController public function upload(UploadProductRequest $request, Product $product) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $product); diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index ce13b57c94..e4b32caa53 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -20,6 +20,7 @@ use App\Http\Requests\Project\ShowProjectRequest; use App\Http\Requests\Project\StoreProjectRequest; use App\Http\Requests\Project\UpdateProjectRequest; use App\Http\Requests\Project\UploadProjectRequest; +use App\Models\Account; use App\Models\Project; use App\Repositories\ProjectRepository; use App\Transformers\ProjectTransformer; @@ -559,6 +560,9 @@ class ProjectController extends BaseController public function upload(UploadProjectRequest $request, Project $project) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $project); diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 5b77721633..ae2c8a750d 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -26,6 +26,7 @@ use App\Http\Requests\Quote\StoreQuoteRequest; use App\Http\Requests\Quote\UpdateQuoteRequest; use App\Http\Requests\Quote\UploadQuoteRequest; use App\Jobs\Invoice\ZipInvoices; +use App\Models\Account; use App\Models\Client; use App\Models\Invoice; use App\Models\Quote; @@ -775,6 +776,9 @@ class QuoteController extends BaseController public function upload(UploadQuoteRequest $request, Quote $quote) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $quote); diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index 0a9ce664d4..e28a59c715 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -21,6 +21,7 @@ use App\Http\Requests\RecurringInvoice\ShowRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest; +use App\Models\Account; use App\Models\RecurringInvoice; use App\Repositories\RecurringInvoiceRepository; use App\Transformers\RecurringInvoiceTransformer; @@ -738,6 +739,9 @@ class RecurringInvoiceController extends BaseController public function upload(UploadRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $recurring_invoice); diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 076b3c3469..247c20e444 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -22,6 +22,7 @@ use App\Http\Requests\Task\ShowTaskRequest; use App\Http\Requests\Task\StoreTaskRequest; use App\Http\Requests\Task\UpdateTaskRequest; use App\Http\Requests\Task\UploadTaskRequest; +use App\Models\Account; use App\Models\Task; use App\Repositories\TaskRepository; use App\Transformers\TaskTransformer; @@ -35,8 +36,8 @@ use Illuminate\Http\Response; /** * Class TaskController. - * @covers App\Http\Controllers\TaskController */ + class TaskController extends BaseController { use MakesHash; @@ -569,6 +570,9 @@ class TaskController extends BaseController public function upload(UploadTaskRequest $request, Task $task) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $task); diff --git a/app/Http/Controllers/VendorController.php b/app/Http/Controllers/VendorController.php index 04394ac0c8..375f82eb6b 100644 --- a/app/Http/Controllers/VendorController.php +++ b/app/Http/Controllers/VendorController.php @@ -22,6 +22,7 @@ use App\Http\Requests\Vendor\ShowVendorRequest; use App\Http\Requests\Vendor\StoreVendorRequest; use App\Http\Requests\Vendor\UpdateVendorRequest; use App\Http\Requests\Vendor\UploadVendorRequest; +use App\Models\Account; use App\Models\Vendor; use App\Repositories\VendorRepository; use App\Transformers\VendorTransformer; @@ -569,6 +570,9 @@ class VendorController extends BaseController public function upload(UploadVendorRequest $request, Vendor $vendor) { + if(!$this->checkFeature(Account::FEATURE_DOCUMENTS)) + return $this->featureFailure(); + if ($request->has('documents')) $this->saveDocuments($request->file('documents'), $vendor);