|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hafijul233\Form\Providers\Components; |
|
4
|
|
|
|
|
5
|
|
|
use Collective\Html\FormFacade as Form; |
|
6
|
|
|
use Illuminate\Support\Facades\Config; |
|
7
|
|
|
use Illuminate\Support\HtmlString; |
|
8
|
|
|
use Illuminate\Support\ServiceProvider; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class GroupFieldServiceProvider |
|
12
|
|
|
*/ |
|
13
|
|
|
class GroupFieldServiceProvider extends ServiceProvider |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var array |
|
17
|
|
|
*/ |
|
18
|
|
|
public $config = []; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Register the service provider. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function register() |
|
26
|
|
|
{ |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get the services provided by the provider. |
|
31
|
|
|
* |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
public function provides() |
|
35
|
|
|
{ |
|
36
|
|
|
return []; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Load All Normal Bootstrap Style Forms |
|
41
|
|
|
* |
|
42
|
|
|
* Example: |
|
43
|
|
|
* |
|
44
|
|
|
* Label |
|
45
|
|
|
* +-----------------------------------+ |
|
46
|
|
|
* | icon | Field | |
|
47
|
|
|
* +-----------------------------------+ |
|
48
|
|
|
* |
|
49
|
|
|
* OR |
|
50
|
|
|
* Label |
|
51
|
|
|
* +-----------------------------------+ |
|
52
|
|
|
* | Field | icon | |
|
53
|
|
|
* +-----------------------------------+ |
|
54
|
|
|
*/ |
|
55
|
|
|
public function boot() |
|
56
|
|
|
{ |
|
57
|
|
|
$style = Config::get('form.style'); |
|
58
|
|
|
|
|
59
|
|
|
if ($style == null) { |
|
60
|
|
|
$style = 'bootstrap4'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @parem string $name |
|
65
|
|
|
* @parem string $label |
|
66
|
|
|
* @parem mixed $default |
|
67
|
|
|
* @parem bool $required |
|
68
|
|
|
* @parem array $attributes |
|
69
|
|
|
* |
|
70
|
|
|
* @return HtmlString |
|
71
|
|
|
*/ |
|
72
|
|
|
Form::component('gText', 'form::'.$style.'.group.text', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
73
|
|
|
/** |
|
74
|
|
|
* @parem string $name |
|
75
|
|
|
* @parem string $label |
|
76
|
|
|
* @parem mixed $default |
|
77
|
|
|
* @parem bool $required |
|
78
|
|
|
* @parem array $attributes |
|
79
|
|
|
* |
|
80
|
|
|
* @return HtmlString |
|
81
|
|
|
*/ |
|
82
|
|
|
Form::component('gEmail', 'form::'.$style.'.group.email', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @parem string $name |
|
86
|
|
|
* @parem string $label |
|
87
|
|
|
* @parem bool $required |
|
88
|
|
|
* @parem array $attributes |
|
89
|
|
|
* |
|
90
|
|
|
* @return HtmlString |
|
91
|
|
|
*/ |
|
92
|
|
|
Form::component('gPassword', 'form::'.$style.'.group.password', ['name', 'label', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @parem string $name |
|
96
|
|
|
* @parem string $label |
|
97
|
|
|
* @parem bool $required |
|
98
|
|
|
* @parem array $attributes |
|
99
|
|
|
* |
|
100
|
|
|
* @return HtmlString |
|
101
|
|
|
*/ |
|
102
|
|
|
Form::component('gSearch', 'form::'.$style.'.group.search', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @parem string $name |
|
106
|
|
|
* @parem string $label |
|
107
|
|
|
* @parem bool $required |
|
108
|
|
|
* @parem array $attributes |
|
109
|
|
|
* |
|
110
|
|
|
* @return HtmlString |
|
111
|
|
|
*/ |
|
112
|
|
|
Form::component('gTel', 'form::'.$style.'.group.tel', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @parem string $name |
|
116
|
|
|
* @parem string $label |
|
117
|
|
|
* @parem bool $required |
|
118
|
|
|
* @parem array $attributes |
|
119
|
|
|
* |
|
120
|
|
|
* @return HtmlString |
|
121
|
|
|
*/ |
|
122
|
|
|
Form::component('gNumber', 'form::'.$style.'.group.number', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @parem string $name |
|
126
|
|
|
* @parem string $label |
|
127
|
|
|
* @parem bool $required |
|
128
|
|
|
* @parem array $attributes |
|
129
|
|
|
* |
|
130
|
|
|
* @return HtmlString |
|
131
|
|
|
*/ |
|
132
|
|
|
Form::component('gDate', 'form::'.$style.'.group.date', ['name', 'label', 'default' => date('Y-m-d'), 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @parem string $name |
|
136
|
|
|
* @parem string $label |
|
137
|
|
|
* @parem bool $required |
|
138
|
|
|
* @parem array $attributes |
|
139
|
|
|
* |
|
140
|
|
|
* @return HtmlString |
|
141
|
|
|
*/ |
|
142
|
|
|
Form::component('gUrl', 'form::'.$style.'.group.url', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @parem string $name |
|
146
|
|
|
* @parem string $label |
|
147
|
|
|
* @parem bool $required |
|
148
|
|
|
* @parem array $attributes |
|
149
|
|
|
* |
|
150
|
|
|
* @return HtmlString |
|
151
|
|
|
*/ |
|
152
|
|
|
Form::component('gTextarea', 'form::'.$style.'.group.textarea', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Create a select box field. |
|
156
|
|
|
* |
|
157
|
|
|
* @param string $name |
|
158
|
|
|
* @param array $list |
|
159
|
|
|
* @param string|bool $selected |
|
160
|
|
|
* @param array $selectAttributes |
|
161
|
|
|
* @param array $optionsAttributes |
|
162
|
|
|
* @param array $optgroupsAttributes |
|
163
|
|
|
*/ |
|
164
|
|
|
Form::component('gSelect', 'form::'.$style.'.group.select', ['name', 'label', 'data', 'selected', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Create a select box field. |
|
168
|
|
|
* |
|
169
|
|
|
* @param string $name |
|
170
|
|
|
* @param array $list |
|
171
|
|
|
* @param string|bool $selected |
|
172
|
|
|
* @param array $selectAttributes |
|
173
|
|
|
* @param array $optionsAttributes |
|
174
|
|
|
* @param array $optgroupsAttributes |
|
175
|
|
|
*/ |
|
176
|
|
|
Form::component('gSelectMulti', 'form::'.$style.'.group.selectmulti', ['name', 'label', 'data' => [], 'selected' => [], 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* Create a select range field. |
|
180
|
|
|
* |
|
181
|
|
|
* @param string $name |
|
182
|
|
|
* @param string $begin |
|
183
|
|
|
* @param string $end |
|
184
|
|
|
* @param string $selected |
|
185
|
|
|
* @param array $options |
|
186
|
|
|
* @return HtmlString |
|
187
|
|
|
*/ |
|
188
|
|
|
Form::component('gSelectRange', 'form::'.$style.'.group.selectrange', ['name', 'label', 'begin', 'end', 'selected', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Create a select day field. |
|
192
|
|
|
* |
|
193
|
|
|
* @param string $name |
|
194
|
|
|
* @param string $selected |
|
195
|
|
|
* @param array $options |
|
196
|
|
|
* @param string $format |
|
197
|
|
|
* @return HtmlString |
|
198
|
|
|
*/ |
|
199
|
|
|
Form::component('gSelectDay', 'form::'.$style.'.group.selectday', ['name', 'label', 'selected' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Create a select month field. |
|
203
|
|
|
* |
|
204
|
|
|
* @param string $name |
|
205
|
|
|
* @param string $selected |
|
206
|
|
|
* @param array $options |
|
207
|
|
|
* @param string $format |
|
208
|
|
|
* @return HtmlString |
|
209
|
|
|
*/ |
|
210
|
|
|
Form::component('gSelectMonth', 'form::'.$style.'.group.selectmonth', ['name', 'label', 'selected' => date('m'), 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
|