| Total Complexity | 8 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class FormSelect extends Component |
||
| 6 | { |
||
| 7 | use HandlesValidationErrors; |
||
| 8 | use HandlesBoundValues; |
||
| 9 | |||
| 10 | public string $name; |
||
| 11 | public string $label; |
||
| 12 | public $options; |
||
| 13 | public $selectedKey; |
||
| 14 | public bool $multiple; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Create a new component instance. |
||
| 18 | * |
||
| 19 | * @return void |
||
| 20 | */ |
||
| 21 | public function __construct( |
||
| 22 | string $name, |
||
| 23 | string $label = '', |
||
| 24 | $options = [], |
||
| 25 | $bind = null, |
||
| 26 | $default = null, |
||
| 27 | bool $multiple = false, |
||
| 28 | bool $showErrors = true |
||
| 29 | ) { |
||
| 30 | $this->name = $name; |
||
| 31 | $this->label = $label; |
||
| 32 | $this->options = $options; |
||
| 33 | |||
| 34 | if ($this->isNotWired()) { |
||
| 35 | $default = $this->getBoundValue($bind, $name) ?: $default; |
||
| 36 | |||
| 37 | $this->selectedKey = old($name, $default); |
||
| 38 | } |
||
| 39 | |||
| 40 | $this->multiple = $multiple; |
||
| 41 | $this->showErrors = $showErrors; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function isSelected($key): bool |
||
| 59 | } |
||
| 60 | } |
||
| 61 |