Conditions | 5 |
Paths | 6 |
Total Lines | 26 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function __construct( |
||
16 | string $name, |
||
17 | string $label = '', |
||
18 | $value = 1, |
||
19 | $bind = null, |
||
20 | bool $default = false, |
||
21 | bool $showErrors = false |
||
22 | ) { |
||
23 | $this->name = $name; |
||
24 | $this->label = $label; |
||
25 | $this->value = $value; |
||
26 | $this->showErrors = $showErrors; |
||
27 | |||
28 | $inputName = static::convertBracketsToDots($name); |
||
29 | |||
30 | if (old($inputName) !== null) { |
||
31 | $this->checked = old($inputName) == $value; |
||
32 | } |
||
33 | |||
34 | if (!session()->hasOldInput() && $this->isNotWired()) { |
||
35 | $boundValue = $this->getBoundValue($bind, $name); |
||
36 | |||
37 | if (!is_null($boundValue)) { |
||
38 | $this->checked = $boundValue == $this->value; |
||
39 | } else { |
||
40 | $this->checked = $default; |
||
41 | } |
||
55 |