Ensure accessory available when checking out via api

This commit is contained in:
Marcus Moore 2024-01-29 16:49:09 -08:00
parent f1ab8253f0
commit 7d45cfff2c
No known key found for this signature in database

View file

@ -278,7 +278,7 @@ class AccessoriesController extends Controller
public function checkout(Request $request, $accessoryId)
{
// Check if the accessory exists
if (is_null($accessory = Accessory::find($accessoryId))) {
if (is_null($accessory = Accessory::withCount('users as users_count')->find($accessoryId))) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));
}