@@ 4-23 (lines=20) @@ | ||
1 | <?php |
|
2 | namespace EngineWorks\Pivot; |
|
3 | ||
4 | class Fields extends Collection |
|
5 | { |
|
6 | protected $itemsInstanceOf = Field::class; |
|
7 | ||
8 | public function addItem($item, $key = null) |
|
9 | { |
|
10 | $key = $item->getFieldname(); |
|
11 | parent::addItem($item, $key); |
|
12 | } |
|
13 | ||
14 | public function asArray() |
|
15 | { |
|
16 | $array = []; |
|
17 | /* @var Field $item */ |
|
18 | foreach ($this->items as $item) { |
|
19 | $array[] = $item->asArray(); |
|
20 | } |
|
21 | return $array; |
|
22 | } |
|
23 | } |
|
24 |
@@ 4-22 (lines=19) @@ | ||
1 | <?php |
|
2 | namespace EngineWorks\Pivot; |
|
3 | ||
4 | class Filters extends Collection |
|
5 | { |
|
6 | protected $itemsInstanceOf = Filter::class; |
|
7 | ||
8 | public function addItem($item, $key = null) |
|
9 | { |
|
10 | return parent::addItem($item, null); |
|
11 | } |
|
12 | ||
13 | public function asArray() |
|
14 | { |
|
15 | $array = []; |
|
16 | /* @var Filter $item */ |
|
17 | foreach ($this->items as $key => $item) { |
|
18 | $array[$key] = $item->asArray(); |
|
19 | } |
|
20 | return $array; |
|
21 | } |
|
22 | } |
|
23 |