| Conditions | 4 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function update(array $data, $id, $attribute = "id") |
||
| 14 | { |
||
| 15 | $model_data = $this->model->where($attribute, '=', $id)->first(); |
||
| 16 | |||
| 17 | if (!$model_data) { |
||
| 18 | throw new NotFoundException(); |
||
| 19 | } |
||
| 20 | |||
| 21 | if (!empty($data['is_main'])) { |
||
| 22 | $this->removeIsMain($model_data->user_id, $id); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (!$model_data->update($data)) { |
||
| 26 | throw new NotSavedException(); |
||
| 27 | } |
||
| 28 | |||
| 29 | return true; |
||
| 30 | } |
||
| 31 | |||
| 37 |