1 | <?php |
||
2 | |||
3 | namespace Laravel\DataTables\Traits; |
||
4 | |||
5 | use Arr; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | |||
8 | trait Updatable |
||
9 | { |
||
10 | /** |
||
11 | * Allow Entity Updating. |
||
12 | * |
||
13 | * @var bool |
||
14 | */ |
||
15 | public $allowUpdating = false; |
||
16 | |||
17 | /** |
||
18 | * @param Model $model |
||
19 | * @param array $data |
||
20 | * @return Model |
||
21 | */ |
||
22 | public function update(Model $model, array $data = []): ?Model |
||
23 | { |
||
24 | if (! $this->allowUpdating) { |
||
25 | return null; |
||
26 | } |
||
27 | |||
28 | return tap($model, function ($model) use ($data) { |
||
29 | $model->update(Arr::only($data, $this->getUpdatableColumns())); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | }); |
||
31 | } |
||
32 | } |
||
33 |