Total Complexity | 6 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
13 | class CompositeBelongsToMany extends BelongsToMany |
||
14 | { |
||
15 | |||
16 | use CompositeRelationships; |
||
17 | |||
18 | |||
19 | /** |
||
20 | * Get all of the IDs from the given mixed value. |
||
21 | * |
||
22 | * @param mixed $value |
||
23 | * @return array |
||
24 | */ |
||
25 | protected function parseIds($value) |
||
26 | { |
||
27 | if ($value instanceof Model) { |
||
28 | return [$this->executeWithinOptionalBinaryTransformation(function() use ($value) { |
||
29 | return $value->{$this->relatedKey}; |
||
30 | }, $value)]; |
||
31 | } |
||
32 | |||
33 | if ($value instanceof Collection) { |
||
34 | return $value->pluck($this->relatedKey)->all(); |
||
35 | } |
||
36 | |||
37 | if ($value instanceof BaseCollection) { |
||
38 | return $value->toArray(); |
||
39 | } |
||
40 | |||
41 | return (array) $value; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get the ID from the given mixed value. |
||
46 | * |
||
47 | * @param mixed $value |
||
48 | * @return mixed |
||
49 | */ |
||
50 | protected function parseId($value) |
||
55 | } |
||
56 | |||
57 | } |