From 5c58265a9007a8b2c628aff7f12b658c4e4b8a8a Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Wed, 18 Oct 2023 12:39:40 +0100 Subject: [PATCH] fix: properly fire custom observables --- framework/core/src/Discussion/Discussion.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Discussion/Discussion.php b/framework/core/src/Discussion/Discussion.php index 321d9c2575..377bd732b3 100644 --- a/framework/core/src/Discussion/Discussion.php +++ b/framework/core/src/Discussion/Discussion.php @@ -85,6 +85,8 @@ class Discussion extends AbstractModel 'hidden_at' => 'datetime', ]; + protected $observables = ['hidden']; + /** * The user for which the state relationship should be loaded. */ @@ -144,7 +146,9 @@ public function hide(?User $actor = null): static $this->raise(new Hidden($this)); - $this->fireCustomModelEvent('hidden', false); + $this->afterSave(function () { + $this->fireCustomModelEvent('hidden', false); + }); } return $this; @@ -158,7 +162,9 @@ public function restore(): static $this->raise(new Restored($this)); - $this->fireCustomModelEvent('restored', false); + $this->afterSave(function () { + $this->fireCustomModelEvent('restored', false); + }); } return $this;