@@ 42-62 (lines=21) @@ | ||
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_null(current($relations))){ |
|
52 | $this->value = null; |
|
53 | } |
|
54 | else if (is_string(current($relations))) { |
|
55 | $this->value = $relations; |
|
56 | } else { |
|
57 | foreach ($relations as $relation) { |
|
58 | $this->value[] = array_get($relation, "pivot.{$this->getOtherKey()}"); |
|
59 | } |
|
60 | } |
|
61 | } |
|
62 | } |
|
63 | ||
64 | public function setOriginal($data) |
|
65 | { |
|
@@ 64-84 (lines=21) @@ | ||
61 | } |
|
62 | } |
|
63 | ||
64 | public function setOriginal($data) |
|
65 | { |
|
66 | $relations = array_get($data, $this->column); |
|
67 | ||
68 | if (is_string($relations)) { |
|
69 | $this->original = explode(',', $relations); |
|
70 | } |
|
71 | ||
72 | if (is_array($relations)) { |
|
73 | if(is_null(current($relations))){ |
|
74 | $this->original = null; |
|
75 | } |
|
76 | else if (is_string(current($relations))) { |
|
77 | $this->original = $relations; |
|
78 | } else { |
|
79 | foreach ($relations as $relation) { |
|
80 | $this->original[] = array_get($relation, "pivot.{$this->getOtherKey()}"); |
|
81 | } |
|
82 | } |
|
83 | } |
|
84 | } |
|
85 | ||
86 | public function prepare($value) |
|
87 | { |