| Total Complexity | 6 |
| Total Lines | 48 |
| 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 | * @return EloquentModel|false |
||
| 17 | */ |
||
| 18 | private function createAddress(string $key = 'address') |
||
| 19 | { |
||
| 20 | return $this->model->address()->save(new Address($this->request->input($key))); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Update an existing Address relationship. |
||
| 25 | * |
||
| 26 | * @param string $key |
||
| 27 | * @return mixed |
||
| 28 | */ |
||
| 29 | private function updateAddress(string $key = 'address') |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Create or update an Address model depending on if the relationship already exists. |
||
| 36 | * |
||
| 37 | * @param string $key |
||
| 38 | * @return bool|false|EloquentModel|mixed |
||
| 39 | */ |
||
| 40 | private function createOrUpdateAddress(string $key = 'address') |
||
| 56 | } |
||
| 57 | } |
||
| 58 |