Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Refactoring Usage of Dynamic Values in HasDraft Trait #48

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Concerns/HasDrafts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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;

Expand Down Expand Up @@ -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'))
Expand Down
Loading