t0berius
1 month ago
429
19
General

collection check for existing IDs inside collection

Posted 1 month ago by t0berius

Using this code:

    //fetch all ids
    $editableStockItemIds = $product->stockItems()->available()->select(['id'])->get();

How can I now perform a check if $request->stockItem are part of editableStockItemIds?

dd($editableStockItemIds->contains('id', [$request->stockItem]));

doesn't work as expected, will I need to loop manually through every item inside the collection?

Please sign in or create an account to participate in this conversation.