Skip to content

Commit cc1cd54

Browse files
authored
fix(DRY): correct deletion checks (#13)
Fix logic in 'dont-repeat-yourself.md' to use whereNull instead of whereNotNull for deleted_at checks
1 parent fbc1678 commit cc1cd54

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/dont-repeat-yourself.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Bad:
77
```php
88
public function getActive(): Collection
99
{
10-
return $this->where('verified', 1)->whereNotNull('deleted_at')->get();
10+
return $this->where('verified', 1)->whereNull('deleted_at')->get();
1111
}
1212

1313
public function getArticles(): Collection
1414
{
1515
return $this->whereHas('user', function ($query) {
16-
$query->where('verified', 1)->whereNotNull('deleted_at');
16+
$query->where('verified', 1)->whereNull('deleted_at');
1717
})->get();
1818
}
1919

@@ -24,7 +24,7 @@ Good:
2424
```php
2525
public function scopeActive(Builder $query): Builder
2626
{
27-
return $query->where('verified', 1)->whereNotNull('deleted_at');
27+
return $query->where('verified', 1)->whereNull('deleted_at');
2828
}
2929

3030
public function getActive(): Collection

0 commit comments

Comments
 (0)