Answers for "check if collection contains laravel"

PHP
1

laravel check if item is in collection

// You may also pass a key / value pair to the contains method,
// which will determine if the given pair exists in the collection:

$collection = collect([
    ['product' => 'Desk', 'price' => 200],
    ['product' => 'Chair', 'price' => 100],
]);

$collection->contains('product', 'Bookcase');
// false
Posted by: Guest on January-14-2021
0

laravel collection contains

$collection = collect([1, 2, 3, 4, 5]);

$collection->contains(function ($value, $key) {
    return $value > 5;
});

// false
Posted by: Guest on September-07-2021

Code answers related to "check if collection contains laravel"

Browse Popular Code Answers by Language