8000 [12.x] Add `Arr::hasAll` method to helpers by milwad-dev · Pull Request #10441 · laravel/docs · GitHub
[go: up one dir, main page]

Skip to content

[12.x] Add Arr::hasAll method to helpers #10441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2025
Merged
Changes from 1 commit
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
Next Next commit
add Arr::hasAll method to helpers
  • Loading branch information
milwad-dev committed May 24, 2025
commit e36427dc518a38f18743933df2dc7bb1fa93a1ec
16 changes: 16 additions & 0 deletions helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[Arr::from](#method-array-from)
[Arr::get](#method-array-get)
[Arr::has](#method-array-has)
[Arr::hasAll](#method-array-hasall)
[Arr::hasAny](#method-array-hasany)
[Arr::integer](#method-array-integer)
[Arr::isAssoc](#method-array-isassoc)
Expand Down Expand Up @@ -557,6 +558,21 @@ $contains = Arr::has($array, ['product.price', 'product.discount']);
// false
```

<a name="method-array-hasall"></a>
#### `Arr::hasAll()` {.collection-method}

The `Arr::hasAll` method checks if all of the specified keys exist in the given array using "dot" notation:

```php
use Illuminate\Support\Arr;

$array = ['name' => 'Taylor', 'language' => 'php'];

Arr::hasAll($array, ['name']); // true
Arr::hasAll($array, ['name', 'language']); // true
Arr::hasAll($array, ['name', 'ide']); // false
```

<a name="method-array-hasany"></a>
#### `Arr::hasAny()` {.collection-method}

Expand Down
0