Skip to content

Commit 12694da

Browse files
ramzengramzeng
andauthored
fix: 修复覆盖 VersionModel 其他方法不生效问题 (#42)
Co-authored-by: ramzeng <[email protected]>
1 parent 14de00a commit 12694da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Versionable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private static function createVersionForModel(Model $model): void
4646

4747
public function versions(): MorphMany
4848
{
49-
return $this->morphMany(\config('versionable.version_model'), 'versionable');
49+
return $this->morphMany($this->getVersionModel(), 'versionable');
5050
}
5151

5252
public function lastVersion(): MorphOne
@@ -56,12 +56,12 @@ public function lastVersion(): MorphOne
5656

5757
public function latestVersion(): MorphOne
5858
{
59-
return $this->morphOne(\config('versionable.version_model'), 'versionable')->latest('id');
59+
return $this->morphOne($this->getVersionModel(), 'versionable')->latest('id');
6060
}
6161

6262
public function firstVersion(): MorphOne
6363
{
64-
return $this->morphOne(\config('versionable.version_model'), 'versionable')->oldest('id');
64+
return $this->morphOne($this->getVersionModel(), 'versionable')->oldest('id');
6565
}
6666

6767
public function getVersion(int $id): ?Version

0 commit comments

Comments
 (0)