| Total Complexity | 6 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 8 | trait SaveAddressTrait |
||
| 9 | { |
||
| 10 | // todo: add use in actions |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Create a new Address related to the Model. |
||
| 14 | * |
||
| 15 | * @param string $key Request key |
||
| 16 | * |
||
| 17 | * @return Model|false |
||
| 18 | */ |
||
| 19 | private function createAddress(string $key = 'address') |
||
| 20 | { |
||
| 21 | return $this->model->address()->save(new Address($this->request->input($key))); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Update an existing Address relationship. |
||
| 26 | * |
||
| 27 | * @param string $key |
||
| 28 | * |
||
| 29 | * @return mixed |
||
| 30 | */ |
||
| 31 | private function updateAddress(string $key = 'address') |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Create or update an Address model depending on if the relationship already exists. |
||
| 38 | * |
||
| 39 | * @param string $key |
||
| 40 | * |
||
| 41 | * @return bool|false|Model|mixed |
||
| 42 | */ |
||
| 43 | private function createOrUpdateAddress(string $key = 'address') |
||
| 59 | } |
||
| 60 | } |
||
| 61 |