| Conditions | 5 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function profileFieldDelete($id): ?string |
||
| 30 | { |
||
| 31 | if (!Any::isInt($id) || $id < 1) { |
||
| 32 | throw new ForbiddenException(); |
||
| 33 | } |
||
| 34 | |||
| 35 | // check if record with $id is exist |
||
| 36 | $record = ProfileField::find($id); |
||
| 37 | if (!$record) { |
||
| 38 | throw new ForbiddenException(); |
||
| 39 | } |
||
| 40 | |||
| 41 | $model = new FormFieldUpdate($record); |
||
| 42 | // if delete is submited - lets remove this record |
||
| 43 | if ($model->send()) { |
||
| 44 | $model->delete(); |
||
| 45 | $this->response->redirect('profile/fieldlist'); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $this->view->render('profile/field_delete', [ |
||
| 49 | 'model' => $model |
||
| 50 | ]); |
||
| 52 | } |