Skip to content

Commit 16a508b

Browse files
committed
Updated readme for 1.3.0
1 parent f77a374 commit 16a508b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class TestModel extends Model
9898

9999
In your JSON you will see `uuid` and `country_uuid` in their textual representation. If you're also making use of composite primary keys, the above works well enough too. Just include your keys in the `$uuids` array or override the `getKeyName()` method on your model and return your composite primary keys as an array of keys. You can also customize the UUID text attribute suffix name. In the code above, instead of '\_text' it's '\_str'.
100100

101+
The `$uuids` array in your model defines fields that will be converted to uuid strings when retrieved and converted to binary when written to the database. You do not need to define these fields in the model `$casts` array in your model.
102+
101103
#### A note on the `uuid` blueprint method
102104

103105
Laravel currently does not allow adding new blueprint methods which can be used out of the box.
@@ -171,6 +173,27 @@ $models = MyModel::withUuid([
171173
])->get();
172174
```
173175

176+
Note: Version 1.3.0 added simplified syntax for finding data using a uuid string.
177+
178+
```php
179+
$uuid = 'ff8683dc-cadd-11e7-9547-8c85901eed2e'; // UUID from eg. the URL.
180+
181+
$model = MyModel::find($uuid);
182+
183+
$model = MyModel::findOrFail($uuid);
184+
```
185+
186+
Version 1.3.0 query for multiple UUIDs.
187+
188+
```php
189+
$uuids = [
190+
'ff8683dc-cadd-11e7-9547-8c85901eed2e',
191+
'ff8683ab-cadd-11e7-9547-8c85900eed2t',
192+
];
193+
194+
$model = MyModel::findMany($uuids);
195+
```
196+
174197
#### Querying relations
175198

176199
You can also use the `withUuid` scope to query relation fields by specifying a field to query.

0 commit comments

Comments
 (0)