1 | <?php |
||
7 | trait UpdateTrait |
||
8 | { |
||
9 | /** |
||
10 | * Non-required attributes. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $nonRequiredAttributes = []; |
||
15 | |||
16 | /** |
||
17 | * Add a non-required attribute. |
||
18 | * |
||
19 | * This method is used for adding attributes that can be left null or blank and should update the model |
||
20 | * accordingly. For example a 'subscribedToNewsletter' column has a boolean. If this returns false then it will be |
||
21 | * missed on the empty($value) check inside updateAttributes() method. This allows this to be set. |
||
22 | * |
||
23 | * @param string $attribute |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | 6 | protected function addNonRequiredAttribute($attribute) |
|
33 | |||
34 | /** |
||
35 | * Remove a non-required attribute. |
||
36 | * |
||
37 | * @param string $attribute |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | 2 | protected function removeNonRequiredAttribute($attribute) |
|
47 | |||
48 | /** |
||
49 | * Get non-required attributes. |
||
50 | * |
||
51 | * @return array |
||
52 | */ |
||
53 | 20 | protected function getNonRequiredAttributes() |
|
57 | |||
58 | /** |
||
59 | * Update attributes. |
||
60 | * |
||
61 | * @param $model |
||
62 | * @param array $data |
||
63 | */ |
||
64 | 18 | protected function updateAttributes(&$model, array &$data) |
|
94 | } |
||
95 |