@@ -28,6 +28,14 @@ composer require verbanent/eloquent-binary-uuid
28
28
29
29
Your model will use an ordered binary UUID, if you prepare a migration:
30
30
31
+ ``` php
32
+ Schema::create('table_name', function (Blueprint $table) {
33
+ $table->uuid('id');
34
+ });
35
+ ```
36
+
37
+ Or if you want to use a custom column name for the primary key:
38
+
31
39
``` php
32
40
Schema::create('table_name', function (Blueprint $table) {
33
41
$table->uuid('uuid');
@@ -58,7 +66,7 @@ use Verbanent\Uuid\AbstractModel;
58
66
59
67
class Lang extends AbstractModel
60
68
{
61
-
69
+ //
62
70
}
63
71
```
64
72
@@ -95,6 +103,11 @@ dd($book->uuid());
95
103
or use a property, if you need a binary value:
96
104
97
105
``` php
106
+ # If you use the default primary key:
107
+ dd($book->id);
108
+ // Output: b"\x11éGù¡½øDˆØ`0ÔƒÅþ"
109
+
110
+ # If you use `uuid` as a primary key:
98
111
dd($book->uuid);
99
112
// Output: b"\x11éGù¡½øDˆØ`0ÔƒÅþ"
100
113
```
@@ -131,9 +144,23 @@ dd($translation->foreignUuid('lang'));
131
144
// Output: "11e947f9-a1bd-f844-88d8-6030d483c5fe"
132
145
```
133
146
134
- Because trying to have an access to the property directly will print binary form of UUID:
147
+ Because trying to have access to the property directly will print binary form of UUID:
135
148
136
149
``` php
137
150
dd($translation->lang);
138
151
// Output: b"\x11éGù¡½øDˆØ`0ÔƒÅþ"
139
152
```
153
+
154
+ ## Unit tests
155
+
156
+ Run this command if you want to check unit tests:
157
+
158
+ ``` shell
159
+ ./vendor/bin/phpunit
160
+ ```
161
+
162
+ Or if you want to check code coverage:
163
+
164
+ ``` shell
165
+ phpdbg -qrr vendor/bin/phpunit --coverage-html coverage tests
166
+ ```
0 commit comments