Checkbox::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 6
1
<?php
2
3
namespace Aminetiyal\LaravelTemplate\Components\Lte\Field;
4
5
use Illuminate\View\Component;
6
use \Illuminate\Support\Str;
7
8
class Checkbox extends Component
9
{
10
    public $id;
11
    public $name;
12
    public $label;
13
    public $value;
14
    public $required;
15
    public $checked;
16
17
    public function __construct(
18
        $id = null,
19
        $name = null,
20
        $label = null,
21
        $value = null,
22
        $required = false,
23
        $checked = false
24
    )
25
    {
26
        $this->id = $id ?? 'field_checkbox_'.rand(100000, 99999);
27
        $this->name = $name ?? str_replace('-', '_', Str::kebab($label));
28
        $this->label = $label;
29
        $this->value = $value;
30
        $this->required = $required;
31
        $this->checked = $checked;
32
    }
33
34
    public function render()
35
    {
36
        return view('template::lte.components._fields.checkbox');
37
    }
38
}
39