|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Spatie\Html\Elements; |
|
4
|
|
|
|
|
5
|
|
|
use Spatie\Html\BaseElement; |
|
6
|
|
|
use Illuminate\Support\Traits\Macroable; |
|
7
|
|
|
|
|
8
|
|
|
class Input extends BaseElement |
|
9
|
|
|
{ |
|
10
|
|
|
use Macroable; |
|
11
|
|
|
|
|
12
|
|
|
protected $tag = 'input'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @return static |
|
16
|
|
|
*/ |
|
17
|
|
|
public function autofocus() |
|
18
|
|
|
{ |
|
19
|
|
|
return $this->attribute('autofocus'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param bool $checked |
|
24
|
|
|
* |
|
25
|
|
|
* @return static |
|
26
|
|
|
*/ |
|
27
|
|
|
public function checked($checked = true) |
|
28
|
|
|
{ |
|
29
|
|
|
return $checked |
|
30
|
|
|
? $this->attribute('checked', 'checked') |
|
31
|
|
|
: $this->forgetAttribute('checked'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param string|null $name |
|
36
|
|
|
* |
|
37
|
|
|
* @return static |
|
38
|
|
|
*/ |
|
39
|
|
|
public function name($name) |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->attribute('name', $name); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string|null $placeholder |
|
46
|
|
|
* |
|
47
|
|
|
* @return static |
|
48
|
|
|
*/ |
|
49
|
|
|
public function placeholder($placeholder) |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->attribute('placeholder', $placeholder); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return static |
|
56
|
|
|
*/ |
|
57
|
|
|
public function required() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->attribute('required'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string|null $type |
|
64
|
|
|
* |
|
65
|
|
|
* @return static |
|
66
|
|
|
*/ |
|
67
|
|
|
public function type($type) |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->attribute('type', $type); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return static |
|
74
|
|
|
*/ |
|
75
|
|
|
public function unchecked() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->checked(false); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string|null $value |
|
82
|
|
|
* |
|
83
|
|
|
* @return static |
|
84
|
|
|
*/ |
|
85
|
|
|
public function value($value) |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->attribute('value', $value); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|