1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

First or fail for company record in short

This commit is contained in:
David Bomba 2020-08-23 07:46:43 +10:00
parent f6c62f3607
commit dbe22cf5fa

View File

@ -34,7 +34,7 @@ class ProductController extends BaseController
*/
public function index(Request $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->firstOrFail();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => new \stdClass],403);
@ -46,7 +46,7 @@ class ProductController extends BaseController
public function show(Request $request, string $product_key)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->firstOrFail();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => new \stdClass],403);