| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | protected function updateResourceRelationships($record, array $relationships) |
||
| 37 | { |
||
| 38 | $relationships = array_intersect_key($relationships, array_flip($this->fillableRelations)); |
||
| 39 | |||
| 40 | foreach ($relationships as $name => $relationship) { |
||
| 41 | $relation = $record->{$name}(); |
||
| 42 | |||
| 43 | if ($relation instanceof BelongsTo) { |
||
| 44 | $record->{$name}()->associate(array_get($relationship, 'data.id')); |
||
| 45 | $record->save(); |
||
| 46 | } else if ($relation instanceof BelongsToMany) { |
||
| 47 | $record->{$name}()->sync(array_pluck($relationship['data'], 'id')); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 |