Input::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Aminetiyal\LaravelTemplate\Components\Lte\Field;
4
5
use Illuminate\View\Component;
6
use Illuminate\Support\Str;
7
8
class Input extends Component
9
{
10
    public $type;
11
    public $name;
12
    public $placeholder;
13
    public $label;
14
    public $value;
15
    public $class;
16
    public $readonly;
17
    public $required;
18
    public $checked;
19
    public $icon;
20
21
    public function __construct(
22
        $type = 'text',
23
        $name = null,
24
        $placeholder = null,
25
        $label = null,
26
        $value = null,
27
        $class = null,
28
        $readonly = null,
29
        $required = false,
30
        $icon = null
31
    )
32
    {
33
        $this->type = $type;
34
        $this->name = $name ?? str_replace('-', '_', Str::kebab($label));
35
        $this->placeholder = $placeholder ?? (!$name ? str_replace('-', '_', Str::kebab($label)) : '');
36
        $this->label = $label;
37
        $this->value = old($this->name, ($value ?? ''));
38
        $this->class = $class;
39
        $this->readonly = $readonly;
40
        $this->required = $required;
41
        $this->icon = $icon;
42
    }
43
44
    public function render()
45
    {
46
        return view('template::lte.components._fields.input');
47
    }
48
}
49