I have the following collection:
$this->items = collect([$productId => [
'name' => $product->title,
'price' => $product->price,
'is_sale' => $product->is_sale,
'sale_price' => $product->sale_price,
'sale_percent' => $product->sale_percent,
'can_use_promocode' => $product->can_use_promocode,
'qty' => 1,
]);
]);
How to search for an item with a key? In the documentation ( https://laravel.com/docs/5.2/collections ) I do not see any methods for this
UPD: For example, a user added an item to the cart ( $this->items
). I want to check the availability of an item in the basket (I need to do this with the key). Analog for php function array_key_exists
, but for collections.
source
share