Skip to content

Commit 865232f

Browse files
committed
String based uuids
1 parent 1b07e73 commit 865232f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

uuid.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The uuid trait automatically generates uuids for your Eloquent models.
1010
- [Primary Key](#primary-key)
1111
- [Custom Column](#custom-column)
1212
- [Scope](#scope)
13+
- [String Based UUIDs](#string-based-uuids)
1314

1415
## Usage
1516

@@ -75,4 +76,29 @@ The trait provides a convenient scope for finding models based on the uuid colum
7576
'5785e0eb-155f-4c25-9e1a-c123a29a0cd8',
7677
'041f681f-9c9b-4ca4-b623-fb9928490e8c',
7778
'93b1e345-b262-4bc7-ad41-034f755a00c3',
78-
])->get()`
79+
])->get()`
80+
81+
## String Based UUIDs
82+
83+
> ⚠️ String based UUIDs are consistently slower on any size dataset. Use this at your own caution ⚠️
84+
85+
Usage is identical to the `BinaryUuid` trait with two differences.
86+
87+
1. You should use the `uuid` type provided by Laravel. This creates a char column type with a length of 36.
88+
2. There is no `uuid_text` attribute, only `uuid`
89+
90+
```php
91+
Schema::table('users', function (Blueprint $table)
92+
{
93+
$table->uuid('uuid');
94+
});
95+
```
96+
97+
```php
98+
use Laratools\Eloquent\Uuid;
99+
100+
class User extends Model
101+
{
102+
use Uuid;
103+
}
104+
```

0 commit comments

Comments
 (0)