SoftDeletesRepository::withTrash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Eloquent\Builder;
4
5
trait SoftDeletesRepository
6
{
7
    public function restore(int $id): bool
8
    {
9
        return $this->getNewBuilderWithScope()->where('id', $id)->restore();
0 ignored issues
show
Bug introduced by
It seems like getNewBuilderWithScope() 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 ignore-call  annotation

9
        return $this->/** @scrutinizer ignore-call */ getNewBuilderWithScope()->where('id', $id)->restore();
Loading history...
10
    }
11
12
    public function forceDelete(int $id): bool
13
    {
14
        return $this->getNewBuilderWithScope()->where('id', $id)->forceDelete();
15
    }
16
17
    public function onlyTrash(): self
18
    {
19
        $this->scope(fn (Builder $builder) => $builder->onlyTrash());
0 ignored issues
show
Bug introduced by
It seems like scope() 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 ignore-call  annotation

19
        $this->/** @scrutinizer ignore-call */ 
20
               scope(fn (Builder $builder) => $builder->onlyTrash());
Loading history...
20
21
        return $this;
22
    }
23
24
    public function withTrash(): self
25
    {
26
        $this->scope(fn (Builder $builder) => $builder->withTrash());
27
28
        return $this;
29
    }
30
}
31