Skip to content

Commit e06f293

Browse files
[12.x] Add Str::uuid7 to string helpers (#10213)
* Add uuid7 string helper * Update strings.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 5d35bc1 commit e06f293

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

strings.md

+18
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
110110
[Str::ulid](#method-str-ulid)
111111
[Str::unwrap](#method-str-unwrap)
112112
[Str::uuid](#method-str-uuid)
113+
[Str::uuid7](#method-str-uuid7)
113114
[Str::wordCount](#method-str-word-count)
114115
[Str::wordWrap](#method-str-word-wrap)
115116
[Str::words](#method-str-words)
@@ -1682,6 +1683,23 @@ To instruct the `uuid` method to return to generating UUIDs normally, you may in
16821683
Str::createUuidsNormally();
16831684
```
16841685

1686+
<a name="method-str-uuid7"></a>
1687+
#### `Str::uuid7()` {.collection-method}
1688+
1689+
The `Str::uuid7` method generates a UUID (version 7):
1690+
1691+
```php
1692+
use Illuminate\Support\Str;
1693+
1694+
return (string) Str::uuid7();
1695+
```
1696+
1697+
A `DateTimeInterface` may be passed as an optional parameter which will be used to generate the ordered UUID:
1698+
1699+
```php
1700+
return (string) Str::uuid7(time: now());
1701+
```
1702+
16851703
<a name="method-str-word-count"></a>
16861704
#### `Str::wordCount()` {.collection-method}
16871705

0 commit comments

Comments
 (0)