Skip to content

Commit

Permalink
fix: properly fire custom observables
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Oct 18, 2023
1 parent 05324a0 commit 5c58265
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions framework/core/src/Discussion/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Discussion extends AbstractModel
'hidden_at' => 'datetime',
];

protected $observables = ['hidden'];

/**
* The user for which the state relationship should be loaded.
*/
Expand Down Expand Up @@ -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);

Check failure on line 150 in framework/core/src/Discussion/Discussion.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.1

Parameter #2 $method of method Illuminate\Database\Eloquent\Model::fireCustomModelEvent() expects string, false given.
});
}

return $this;
Expand All @@ -158,7 +162,9 @@ public function restore(): static

$this->raise(new Restored($this));

$this->fireCustomModelEvent('restored', false);
$this->afterSave(function () {
$this->fireCustomModelEvent('restored', false);

Check failure on line 166 in framework/core/src/Discussion/Discussion.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.1

Parameter #2 $method of method Illuminate\Database\Eloquent\Model::fireCustomModelEvent() expects string, false given.
});
}

return $this;
Expand Down

0 comments on commit 5c58265

Please sign in to comment.