diff --git a/app/Http/Controllers/Shop/ClientController.php b/app/Http/Controllers/Shop/ClientController.php index 31002e57b4fd..52800c568bb9 100644 --- a/app/Http/Controllers/Shop/ClientController.php +++ b/app/Http/Controllers/Shop/ClientController.php @@ -53,6 +53,9 @@ class ClientController extends BaseController { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + $contact = ClientContact::with('client') ->where('company_id', $company->id) ->where('contact_key', $contact_key) @@ -65,6 +68,9 @@ class ClientController extends BaseController { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + app('queue')->createPayloadUsing(function () use ($company) { return ['db' => $company->db]; }); diff --git a/app/Http/Controllers/Shop/InvoiceController.php b/app/Http/Controllers/Shop/InvoiceController.php index 198613dc516e..ace6fef91abd 100644 --- a/app/Http/Controllers/Shop/InvoiceController.php +++ b/app/Http/Controllers/Shop/InvoiceController.php @@ -54,6 +54,9 @@ class InvoiceController extends BaseController { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + $invitation = InvoiceInvitation::with(['invoice']) ->where('company_id', $company->id) ->where('key',$invitation_key) @@ -65,12 +68,16 @@ class InvoiceController extends BaseController public function store(StoreInvoiceRequest $request) { - app('queue')->createPayloadUsing(function () use ($company) { - return ['db' => $company->db]; - }); $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + + app('queue')->createPayloadUsing(function () use ($company) { + return ['db' => $company->db]; + }); + $client = Client::find($request->input('client_id')); $invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create($company_id, $company->owner()->id)); diff --git a/app/Http/Controllers/Shop/ProductController.php b/app/Http/Controllers/Shop/ProductController.php index 5122ba1918c4..77ad20530799 100644 --- a/app/Http/Controllers/Shop/ProductController.php +++ b/app/Http/Controllers/Shop/ProductController.php @@ -36,6 +36,9 @@ class ProductController extends BaseController { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + $products = Product::where('company_id', $company->id); return $this->listResponse($products); @@ -45,6 +48,9 @@ class ProductController extends BaseController { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); + if(!$company->enable_shop_api) + return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); + $product = Product::where('company_id', $company->id) ->where('product_key', $product_key) ->first();