Tell scheduling apart from unpublishing in the history

Giving a record a future date was recorded as "unpublished", and announced
to webhooks as such. The history now compares before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 10:09:03 +02:00
parent 1fe1e67773
commit 70521d4bc9
7 changed files with 35 additions and 15 deletions

View File

@@ -131,11 +131,23 @@ trait HasRevisions
// Ask the model itself: "published" means different things to a page
// with a status and a project with only a date.
if (method_exists($this, 'isPublishedNow')) {
return $this->isPublishedNow() ? 'published' : 'unpublished';
if (! method_exists($this, 'isPublishedNow')) {
return 'updated';
}
return 'updated';
// Before and after, because the change is what has a name: going live,
// coming off, or being given a date — which is neither, and which a
// history that only asked "is it live now?" called "unpublished".
$before = (clone $this)->setRawAttributes($this->getRawOriginal());
$now = $this->isPublishedNow();
$was = $before->isPublishedNow();
return match (true) {
$now && ! $was => 'published',
! $now && $was => 'unpublished',
! $now && method_exists($this, 'isScheduled') && $this->isScheduled() => 'scheduled',
default => 'updated',
};
}
protected function revisionValue(mixed $value): mixed