Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #82 from louisl/feature/update-readme
Browse files Browse the repository at this point in the history
Feature/update readme
  • Loading branch information
brendt authored Oct 24, 2018
2 parents f77a374 + 97dc33a commit 2aed784
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class TestModel extends Model

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'.

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 `$casts` array in your model.

#### A note on the `uuid` blueprint method

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

Note: Version 1.3.0 added simplified syntax for finding data using a uuid string.

```php
$uuid = 'ff8683dc-cadd-11e7-9547-8c85901eed2e'; // UUID from eg. the URL.

$model = MyModel::find($uuid);

$model = MyModel::findOrFail($uuid);
```

Version 1.3.0 query for multiple UUIDs.

```php
$uuids = [
'ff8683dc-cadd-11e7-9547-8c85901eed2e',
'ff8683ab-cadd-11e7-9547-8c85900eed2t',
];

$model = MyModel::findMany($uuids);
```

#### Querying relations

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

0 comments on commit 2aed784

Please sign in to comment.