Skip to content

Commit 5ad16f5

Browse files
FIX exclusion wildcard (#25)
1 parent 749df09 commit 5ad16f5

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/Excludable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public function excluded(): bool
5151

5252
public function addToExclusion(): bool
5353
{
54+
if ($this->excluded()) {
55+
return true;
56+
}
57+
5458
if ($this->fireModelEvent('excluding') === false) {
5559
return false;
5660
}

src/Support/MorphManyWildcard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function addConstraints(): void
3434
->whereNotNull($this->foreignKey)
3535
->where(
3636
fn (Builder $query) => $query
37-
->where($this->foreignKey, $this->getParentKey())
37+
->where($this->foreignKey, (string) $this->getParentKey())
3838
->orWhere($this->foreignKey, '*')
3939
);
4040
}

src/Support/MorphOneWildcard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function addConstraints(): void
3535
->whereNotNull($this->foreignKey)
3636
->where(
3737
fn (Builder $query) => $query
38-
->where($this->foreignKey, $this->getParentKey())
38+
->where($this->foreignKey, (string) $this->getParentKey())
3939
->orWhere($this->foreignKey, '*')
4040
);
4141
}

tests/ExclusionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function it_can_exclude_all_models()
104104

105105
Article::excludeAllModels();
106106

107+
$articles->first()->addToExclusion();
108+
107109
$this->assertCount(0, Article::all());
108110
$this->assertDatabaseCount($this->exclusionsTable, 1);
109111
$this->assertDatabaseHas($this->exclusionsTable, [

0 commit comments

Comments
 (0)