Deletable::destroy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Laravel\DataTables\Traits;
4
5
trait Deletable
6
{
7
    /**
8
     * Allow Entity Deleting.
9
     *
10
     * @var bool
11
     */
12
    public $allowDeleting = false;
13
14
    /**
15
     * @param Model $result
0 ignored issues
show
Bug introduced by
The type Laravel\DataTables\Traits\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
     * @param Request $request
0 ignored issues
show
Bug introduced by
The type Laravel\DataTables\Traits\Request was not found. Did you mean Request? If so, make sure to prefix the type with \.
Loading history...
17
     * @return bool|null
18
     */
19
    public function destroy($ids): ?bool
20
    {
21
        $ids = (array) $ids;
22
        if (! $this->allowDeleting) {
23
            return null;
24
        }
25
26
        return $this->builder()->whereIn(
0 ignored issues
show
Bug introduced by
It seems like builder() 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

26
        return $this->/** @scrutinizer ignore-call */ builder()->whereIn(
Loading history...
27
            $this->builder()->getModel()->getQualifiedKeyName(),
28
            $ids
29
        )->delete();
30
    }
31
}
32