We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 946bc11 commit e4266f0Copy full SHA for e4266f0
src/Traits/GenUid.php
@@ -0,0 +1,40 @@
1
+<?php
2
+
3
+namespace LaravelEasyRepository\Mutators;
4
5
6
+trait GenUid
7
+{
8
+ /**
9
+ * Boot function from Laravel.
10
+ */
11
+ protected static function boot()
12
+ {
13
+ parent::boot();
14
+ static::creating(function ($model) {
15
+ if (empty($model->{$model->getKeyName()})) {
16
+ $model->{$model->getKeyName()} = uid();
17
+ }
18
+ });
19
20
21
22
+ * Get the value indicating whether the IDs are incrementing.
23
+ *
24
+ * @return bool
25
26
+ public function getIncrementing()
27
28
+ return false;
29
30
31
32
+ * Get the auto-incrementing key type.
33
34
+ * @return string
35
36
+ public function getKeyType()
37
38
+ return 'string';
39
40
+}
0 commit comments