There was an error while loading. Please reload this page.
1 parent 2476ecb commit 30d9e87Copy full SHA for 30d9e87
1 file changed
src/Model/Concerns/HasUuids.php
@@ -63,4 +63,27 @@ public function getIncrementing()
63
64
return $this->incrementing;
65
}
66
+
67
+ /**
68
+ * Initialize the model with unique identifiers.
69
+ *
70
+ * @param array $columns
71
+ * @return void
72
+ */
73
+ protected function initialize(array $columns): void
74
+ {
75
+ foreach ($columns as $column) {
76
+ if (in_array($column, $this->uniqueIds()) && ! $this->{$column}) {
77
+ $this->{$column} = $this->newUniqueId();
78
+ }
79
80
81
82
+ public function save(array $options = []): bool
83
84
+ $this->initialize($this->uniqueIds());
85
86
+ return parent::save($options);
87
88
89
0 commit comments