1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace crmeb\form\components;
- use crmeb\form\BuildInterface;
- class Card implements BuildInterface
- {
-
- const NAME = 'card';
-
- protected $rule = [
- 'componentsModel' => [],
- 'title' => '',
- ];
-
- public function __construct(string $title)
- {
- $this->rule['title'] = $title;
- }
-
- public function components(array $components = [])
- {
- $this->rule['componentsModel'] = $components;
- return $this;
- }
-
- public function toArray(): array
- {
- $this->rule['name'] = self::NAME;
- $componentsModel = [];
- foreach ($this->rule['componentsModel'] as $item) {
- if ($item instanceof BuildInterface) {
- $componentsModel[] = $item->toArray();
- }
- }
- $this->rule['componentsModel'] = $componentsModel;
- return $this->rule;
- }
- }
|