1 | <?php |
||||||
2 | /** |
||||||
3 | * Created by enea dhack - 28/12/2019 16:06. |
||||||
4 | */ |
||||||
5 | |||||||
6 | namespace Vaened\Searcher; |
||||||
7 | |||||||
8 | use Vaened\Searcher\Constraints\IsNotNull; |
||||||
9 | use Vaened\Searcher\Constraints\IsNull; |
||||||
10 | |||||||
11 | trait SoftDeletes |
||||||
12 | { |
||||||
13 | public function withTrashed(): self |
||||||
14 | { |
||||||
15 | $this->removeNamedBinding(SoftDeletes::class); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
16 | return $this; |
||||||
17 | } |
||||||
18 | |||||||
19 | public function withoutTrashed(): self |
||||||
20 | { |
||||||
21 | $this->removeNamedBinding(SoftDeletes::class); |
||||||
22 | $this->apply(new IsNull($this->getDeletedAtColumnName())); |
||||||
0 ignored issues
–
show
It seems like
apply() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
23 | return $this; |
||||||
24 | } |
||||||
25 | |||||||
26 | public function onlyTrashed(): self |
||||||
27 | { |
||||||
28 | $this->removeNamedBinding(SoftDeletes::class); |
||||||
29 | $this->apply(new IsNotNull($this->getDeletedAtColumnName())); |
||||||
30 | return $this; |
||||||
31 | } |
||||||
32 | |||||||
33 | protected function getSoftDeletesDefaultBindings(): array |
||||||
34 | { |
||||||
35 | if (! $this->isTrashFilterActivated()) { |
||||||
36 | return []; |
||||||
37 | } |
||||||
38 | |||||||
39 | return [ |
||||||
40 | Binding::named(SoftDeletes::class, [ |
||||||
41 | new IsNull($this->getDeletedAtColumnName()), |
||||||
42 | ]), |
||||||
43 | ]; |
||||||
44 | } |
||||||
45 | |||||||
46 | protected function getDeletedAtColumnName(): string |
||||||
47 | { |
||||||
48 | return 'deleted_at'; |
||||||
49 | } |
||||||
50 | |||||||
51 | protected function isTrashFilterActivated(): bool |
||||||
52 | { |
||||||
53 | return true; |
||||||
54 | } |
||||||
55 | } |
||||||
56 |