Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ For the majority of the remaining collection documentation, we'll discuss each m
[combine](#method-combine)
[concat](#method-concat)
[contains](#method-contains)
[containsManyItems](#method-containsmanyitems)
[containsStrict](#method-containsstrict)
[count](#method-count)
[countBy](#method-countBy)
Expand Down Expand Up @@ -154,6 +153,7 @@ For the majority of the remaining collection documentation, we'll discuss each m
[groupBy](#method-groupby)
[has](#method-has)
[hasAny](#method-hasany)
[hasMany](#method-hasmany)
[hasSole](#method-hassole)
[implode](#method-implode)
[intersect](#method-intersect)
Expand Down Expand Up @@ -577,29 +577,6 @@ The `contains` method uses "loose" comparisons when checking item values, meanin

For the inverse of `contains`, see the [doesntContain](#method-doesntcontain) method.

<a name="method-containsmanyitems"></a>
#### `containsManyItems()` {.collection-method}

The `containsManyItems` method determines whether the collection contains multiple items:

```php
collect([])->containsManyItems(); // false
collect(['1'])->containsManyItems(); // false
collect(['1', '2'])->containsManyItems(); // true
```

You may also pass a callback to determine if multiple items in the collection match a given condition:

```php
collect([1, 2, 3])->containsManyItems(fn (int $item) => $item > 1);

// true

collect([1, 2, 3])->containsManyItems(fn (int $item) => $item > 5);

// false
```

<a name="method-containsstrict"></a>
#### `containsStrict()` {.collection-method}

Expand Down Expand Up @@ -1438,6 +1415,32 @@ $collection->hasAny(['name', 'price']);
// false
```

<a name="method-hasmany"></a>
#### `hasMany()` {.collection-method}

The `hasMany` method determines whether the collection contains multiple items:

```php
collect([])->hasMany();

// false

collect(['1'])->hasMany();

// false

collect([1, 2, 3])->hasMany();

// true

collect([
['age' => 2],
['age' => 3],
])->hasMany(fn ($item) => $item['age'] === 2)

// false
```

<a name="method-hassole"></a>
#### `hasSole()` {.collection-method}

Expand Down