1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

check shop is enabled

This commit is contained in:
David Bomba 2020-07-28 22:12:33 +10:00
parent 2b9610ea02
commit 52065fb963
3 changed files with 22 additions and 3 deletions

View File

@ -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];
});

View File

@ -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));

View File

@ -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();