@@ 42-59 (lines=18) @@ | ||
39 | throw new \Exception('Column of this field must be a `BelongsToMany` relation.'); |
|
40 | } |
|
41 | ||
42 | public function fill($data) |
|
43 | { |
|
44 | $relations = array_get($data, $this->column); |
|
45 | ||
46 | if (is_string($relations)) { |
|
47 | $this->value = explode(',', $relations); |
|
48 | } |
|
49 | ||
50 | if (is_array($relations)) { |
|
51 | if (is_string(current($relations))) { |
|
52 | $this->value = $relations; |
|
53 | } else { |
|
54 | foreach ($relations as $relation) { |
|
55 | $this->value[] = array_get($relation, "pivot.{$this->getOtherKey()}"); |
|
56 | } |
|
57 | } |
|
58 | } |
|
59 | } |
|
60 | ||
61 | public function setOriginal($data) |
|
62 | { |
|
@@ 61-78 (lines=18) @@ | ||
58 | } |
|
59 | } |
|
60 | ||
61 | public function setOriginal($data) |
|
62 | { |
|
63 | $relations = array_get($data, $this->column); |
|
64 | ||
65 | if (is_string($relations)) { |
|
66 | $this->original = explode(',', $relations); |
|
67 | } |
|
68 | ||
69 | if (is_array($relations)) { |
|
70 | if (is_string(current($relations))) { |
|
71 | $this->original = $relations; |
|
72 | } else { |
|
73 | foreach ($relations as $relation) { |
|
74 | $this->original[] = array_get($relation, "pivot.{$this->getOtherKey()}"); |
|
75 | } |
|
76 | } |
|
77 | } |
|
78 | } |
|
79 | ||
80 | public function prepare($value) |
|
81 | { |