diff --git a/src/Concerns/HasDrafts.php b/src/Concerns/HasDrafts.php index 70c5ab4..a40d8e9 100644 --- a/src/Concerns/HasDrafts.php +++ b/src/Concerns/HasDrafts.php @@ -92,7 +92,7 @@ protected function newRevision(): void // This model has been set not to create a revision || $this->shouldCreateRevision() === false // The record is being soft deleted or restored - || $this->isDirty('deleted_at') + || $this->isDirty(method_exists($this, 'getDeletedAtColumn') ? $this->getDeletedAtColumn() : 'deleted_at') // A listener of the creatingRevision event returned false || $this->fireModelEvent('creatingRevision') === false ) { @@ -106,8 +106,8 @@ protected function newRevision(): void return; } - $revision->created_at = $this->created_at; - $revision->updated_at = $this->updated_at; + $revision->{$this->getCreatedAtColumn()} = $this->{$this->getCreatedAtColumn()}; + $revision->{$this->getUpdatedAtColumn()} = $this->{$this->getUpdatedAtColumn()}; $revision->is_current = false; $revision->is_published = false; @@ -337,7 +337,7 @@ public function pruneRevisions() { self::withoutEvents(function () { $revisionsToKeep = $this->revisions() - ->orderByDesc('updated_at') + ->orderByDesc($this->getUpdatedAtColumn()) ->onlyDrafts() ->withoutCurrent() ->take(config('drafts.revisions.keep'))