File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,14 @@ trait HasDocumentVersion
16
16
public static function bootHasDocumentVersion (): void
17
17
{
18
18
static ::saving (function ($ model ) {
19
- $ versionKey = static :: getDocumentVersionKey ();
20
- if (! empty ($ versionKey )) {
21
- $ model ->{$ versionKey } = $ model ->documentVersion ?? 1 ;
22
- }
19
+ $ version = $ model -> getDocumentVersion ();
20
+ if (empty ($ version )) {
21
+ $ model ->{static :: getDocumentVersionKey () } = $ model ->documentVersion ?? 1 ;
22
+ }
23
23
});
24
24
25
25
static ::retrieved (function ($ model ) {
26
- $ model ->migrateDocumentVersion ($ model ->getDocumentVersion ());
26
+ $ model ->migrateDocumentVersion ($ model ->getDocumentVersion () ?? 0 );
27
27
});
28
28
}
29
29
@@ -38,11 +38,11 @@ public function migrateDocumentVersion(int $fromVersion): void {}
38
38
/**
39
39
* Get Current document version
40
40
*
41
- * @return int
41
+ * @return int|null
42
42
*/
43
- public function getDocumentVersion (): int
43
+ public function getDocumentVersion (): ? int
44
44
{
45
- return ( int ) $ this ->{static ::getDocumentVersionKey ()} ?? 0 ;
45
+ return $ this ->{static ::getDocumentVersionKey ()} ?? null ;
46
46
}
47
47
48
48
/**
You can’t perform that action at this time.
0 commit comments