diff --git a/src/Excludable.php b/src/Excludable.php index 68eb46d..c9e85f1 100644 --- a/src/Excludable.php +++ b/src/Excludable.php @@ -61,6 +61,10 @@ public static function areAllExcluded(): bool public function addToExclusion(): bool { return DB::transaction(function () { + if ($this->fireModelEvent('excluding') === false) { + return false; + } + $this->exclusions()->where([ 'type' => Exclusion::TYPE_INCLUDE, 'excludable_type' => $this->getMorphClass(), @@ -71,10 +75,6 @@ public function addToExclusion(): bool return true; } - if ($this->fireModelEvent('excluding') === false) { - return false; - } - $exclusion = $this->exclusion()->firstOrCreate([ 'type' => Exclusion::TYPE_EXCLUDE, 'excludable_type' => $this->getMorphClass(),