@@ 9-36 (lines=28) @@ | ||
6 | use SleepingOwl\Admin\Contracts\Display\TabInterface; |
|
7 | use SleepingOwl\Admin\Contracts\FormElementInterface; |
|
8 | ||
9 | class DisplayTabsCollection extends FormElementsCollection |
|
10 | { |
|
11 | /** |
|
12 | * @return static |
|
13 | */ |
|
14 | public function onlyActive() |
|
15 | { |
|
16 | return $this->filter(function (TabInterface $tab) { |
|
17 | $element = $tab->getContent(); |
|
18 | ||
19 | if ($element instanceof FormElementInterface) { |
|
20 | return ! $element->isReadonly(); |
|
21 | } |
|
22 | ||
23 | return true; |
|
24 | })->onlyVisible(); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @return static |
|
29 | */ |
|
30 | public function onlyVisible() |
|
31 | { |
|
32 | return $this->filter(function (TabInterface $tab) { |
|
33 | return $tab->isVisible(); |
|
34 | }); |
|
35 | } |
|
36 | } |
|
37 |
@@ 8-37 (lines=30) @@ | ||
5 | use Illuminate\Support\Collection; |
|
6 | use SleepingOwl\Admin\Contracts\FormElementInterface; |
|
7 | ||
8 | class FormElementsCollection extends Collection |
|
9 | { |
|
10 | /** |
|
11 | * @return static |
|
12 | */ |
|
13 | public function onlyActive() |
|
14 | { |
|
15 | return $this->filter(function ($element) { |
|
16 | if ($element instanceof FormElementInterface) { |
|
17 | return ! $element->isReadonly(); |
|
18 | } |
|
19 | ||
20 | return true; |
|
21 | })->onlyVisible(); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @return static |
|
26 | */ |
|
27 | public function onlyVisible() |
|
28 | { |
|
29 | return $this->filter(function ($element) { |
|
30 | if ($element instanceof FormElementInterface) { |
|
31 | return $element->isVisible(); |
|
32 | } |
|
33 | ||
34 | return true; |
|
35 | }); |
|
36 | } |
|
37 | } |
|
38 |