File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -19,19 +19,26 @@ class Toggle extends Component
19
19
* @var string
20
20
*/
21
21
public $ name ;
22
+ /**
23
+ * Whether or not the toggle is checked.
24
+ *
25
+ * @var bool
26
+ */
27
+ public $ checked ;
22
28
23
29
/**
24
30
* Create a new component instance.
25
31
*
26
32
* @param string $name
27
- * @param string $checked
33
+ * @param bool $checked
28
34
*
29
35
* @return void
30
36
*/
31
- public function __construct ($ name = "toggle " )
37
+ public function __construct ($ name = "toggle " , $ checked = false )
32
38
{
33
39
$ this ->id = 'form- ' . Str::kebab (class_basename (get_class ($ this ))) . '- ' . md5 ($ name );
34
40
$ this ->name = $ name ;
41
+ $ this ->checked = $ checked ;
35
42
}
36
43
37
44
/**
Original file line number Diff line number Diff line change 1
1
<label {{ $attributes -> merge ([' class' => ' form-check form-switch' ]) } } >
2
- <input name =" {{ $name } }" type =" checkbox" class =" form-check-input" >
2
+ <input name =" {{ $name } }" type =" checkbox" class =" form-check-input" {{ $checked ? ' checked ' : old ( $name ) } } >
3
3
<span class =" form-check-label" >{{ $slot } } </span >
4
4
@error ($name )
5
5
<div class =" form-check-description invalid-feedback" >{{ $message } } </div >
You can’t perform that action at this time.
0 commit comments