Issues (17)

src/Traits/Creatable.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Laravel\DataTables\Traits;
4
5
use Arr;
6
use Illuminate\Database\Eloquent\Model;
7
8
trait Creatable
9
{
10
    /**
11
     * Allow Entity Creation.
12
     *
13
     * @var bool
14
     */
15
    public $allowCreation = false;
16
17
    /**
18
     * @param array $data
19
     * @return mixed
20
     */
21
    public function create(array $data): ?Model
22
    {
23
        if (! $this->allowCreation) {
24
            return null;
25
        }
26
27
        return $this->builder()->create(
0 ignored issues
show
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

27
        return $this->/** @scrutinizer ignore-call */ builder()->create(
Loading history...
28
            Arr::only(
29
                $data,
30
                $this->getUpdatableColumns()
0 ignored issues
show
It seems like getUpdatableColumns() 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

30
                $this->/** @scrutinizer ignore-call */ 
31
                       getUpdatableColumns()
Loading history...
31
            )
32
        );
33
    }
34
}
35