FormBuilder::image()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\LaravelHtml\Contracts;
6
7
use Arcanedev\Html\Elements\{Button, File, Input, Label, Select, Textarea};
8
use Illuminate\Contracts\Session\Session;
9
use Illuminate\Support\HtmlString;
10
11
/**
12
 * Interface  FormBuilder
13
 *
14
 * @author    ARCANEDEV <[email protected]>
15
 */
16
interface FormBuilder
17
{
18
    /* -----------------------------------------------------------------
19
     |  Getters & Setters
20
     | -----------------------------------------------------------------
21
     */
22
23
    /**
24
     * Get the session store implementation.
25
     *
26
     * @return \Illuminate\Contracts\Session\Session|null
27
     */
28
    public function getSessionStore(): ?Session;
29
30
    /**
31
     * Set the session store implementation.
32
     *
33
     * @param  \Illuminate\Contracts\Session\Session  $session
34
     *
35
     * @return $this
36
     */
37
    public function setSessionStore(Session $session);
38
39
    /**
40
     * Set the model instance on the form builder.
41
     *
42
     * @param  \Illuminate\Database\Eloquent\Model|mixed  $model
43
     *
44
     * @return $this
45
     */
46
    public function setModel($model);
47
48
    /**
49
     * Get the model instance on the form builder.
50
     *
51
     * @return \Illuminate\Database\Eloquent\Model|mixed|null
52
     */
53
    public function getModel();
54
55
    /**
56
     * Get the ID attribute for a field name.
57
     *
58
     * @param  string|null  $name
59
     * @param  array        $attributes
60
     *
61
     * @return string|null
62
     */
63
    public function getIdAttribute($name, array $attributes): ?string;
64
65
    /**
66
     * Get the value that should be assigned to the field.
67
     *
68
     * @param  string  $name
69
     * @param  string  $value
70
     *
71
     * @return mixed
72
     */
73
    public function getValueAttribute($name, $value = null);
74
75
    /**
76
     * Determine if the old input is empty.
77
     *
78
     * @return bool
79
     */
80
    public function oldInputIsEmpty();
81
82
    /* -----------------------------------------------------------------
83
     |  Main Methods
84
     | -----------------------------------------------------------------
85
     */
86
87
    /**
88
     * Open up a new HTML form.
89
     *
90
     * @param  array  $attributes
91
     *
92
     * @return \Illuminate\Support\HtmlString
93
     */
94
    public function open(array $attributes = []): HtmlString;
95
96
    /**
97
     * Create a new model based form builder.
98
     *
99
     * @param  mixed  $model
100
     * @param  array  $attributes
101
     *
102
     * @return \Illuminate\Support\HtmlString
103
     */
104
    public function model($model, array $attributes = []): HtmlString;
105
106
    /**
107
     * Close the current form.
108
     *
109
     * @return \Illuminate\Support\HtmlString
110
     */
111
    public function close(): HtmlString;
112
113
    /**
114
     * Generate a hidden field with the current CSRF token.
115
     *
116
     * @return \Arcanedev\Html\Elements\Input
117
     */
118
    public function token(): Input;
119
120
    /**
121
     * Create a form label element.
122
     *
123
     * @param  string  $name
124
     * @param  string  $value
125
     * @param  array   $attributes
126
     * @param  bool    $escaped
127
     *
128
     * @return \Arcanedev\Html\Elements\Label
129
     */
130
    public function label(string $name, $value = null, array $attributes = [], $escaped = true): Label;
131
132
    /**
133
     * Create a form input field.
134
     *
135
     * @param  string        $type
136
     * @param  string|null   $name
137
     * @param  string|mixed  $value
138
     * @param  array         $attributes
139
     *
140
     * @return \Arcanedev\Html\Elements\Input
141
     */
142
    public function input(string $type, string $name, $value = null, array $attributes = []): Input;
143
144
    /**
145
     * Create a text input field.
146
     *
147
     * @param  string        $name
148
     * @param  string|mixed  $value
149
     * @param  array         $attributes
150
     *
151
     * @return \Arcanedev\Html\Elements\Input
152
     */
153
    public function text(string $name, $value = null, array $attributes = []): Input;
154
155
    /**
156
     * Create a password input field.
157
     *
158
     * @param  string  $name
159
     * @param  array   $attributes
160
     *
161
     * @return \Arcanedev\Html\Elements\Input
162
     */
163
    public function password(string $name, array $attributes = []): Input;
164
165
    /**
166
     * Create a hidden input field.
167
     *
168
     * @param  string  $name
169
     * @param  string  $value
170
     * @param  array   $attributes
171
     *
172
     * @return \Arcanedev\Html\Elements\Input
173
     */
174
    public function hidden(string $name, $value = null, array $attributes = []): Input;
175
176
    /**
177
     * Create an e-mail input field.
178
     *
179
     * @param  string  $name
180
     * @param  string  $value
181
     * @param  array   $attributes
182
     *
183
     * @return \Arcanedev\Html\Elements\Input
184
     */
185
    public function email(string $name, $value = null, array $attributes = []): Input;
186
187
    /**
188
     * Create a tel input field.
189
     *
190
     * @param  string  $name
191
     * @param  string  $value
192
     * @param  array   $attributes
193
     *
194
     * @return \Arcanedev\Html\Elements\Input
195
     */
196
    public function tel(string $name, $value = null, array $attributes = []): Input;
197
198
    /**
199
     * Create a number input field.
200
     *
201
     * @param  string  $name
202
     * @param  string  $value
203
     * @param  array   $attributes
204
     *
205
     * @return \Arcanedev\Html\Elements\Input
206
     */
207
    public function number(string $name, $value = null, array $attributes = []): Input;
208
209
    /**
210
     * Create a date input field.
211
     *
212
     * @param  string  $name
213
     * @param  string  $value
214
     * @param  array   $attributes
215
     *
216
     * @return \Arcanedev\Html\Elements\Input
217
     */
218
    public function date(string $name, $value = null, array $attributes = []): Input;
219
220
    /**
221
     * Create a time input field.
222
     *
223
     * @param  string  $name
224
     * @param  string  $value
225
     * @param  array   $attributes
226
     *
227
     * @return \Arcanedev\Html\Elements\Input
228
     */
229
    public function time(string $name, $value = null, array $attributes = []): Input;
230
231
    /**
232
     * Create a url input field.
233
     *
234
     * @param  string  $name
235
     * @param  string  $value
236
     * @param  array   $attributes
237
     *
238
     * @return \Arcanedev\Html\Elements\Input
239
     */
240
    public function url(string $name, $value = null, array $attributes = []): Input;
241
242
    /**
243
     * Create a file input field.
244
     *
245
     * @param  string  $name
246
     * @param  array   $attributes
247
     *
248
     * @return \Arcanedev\Html\Elements\File
249
     */
250
    public function file(string $name, array $attributes = []): File;
251
252
    /**
253
     * Create a textarea input field.
254
     *
255
     * @param  string  $name
256
     * @param  string  $value
257
     * @param  array   $attributes
258
     *
259
     * @return \Arcanedev\Html\Elements\Textarea
260
     */
261
    public function textarea(string $name, $value = null, array $attributes = []): Textarea;
262
263
    /**
264
     * Create a select box field.
265
     *
266
     * @param  string                                         $name
267
     * @param  array|\Illuminate\Support\Collection|iterable  $list
268
     * @param  string|bool                                    $selected
269
     * @param  array                                          $attributes
270
     * @param  array                                          $optionsAttributes
271
     * @param  array                                          $optgroupsAttributes
272
     *
273
     * @return \Arcanedev\Html\Elements\Select
274
     */
275
    public function select(
276
        string $name, iterable $list = [], $selected = null,
277
        array $attributes = [], array $optionsAttributes = [], array $optgroupsAttributes = []
278
    ): Select;
279
280
    /**
281
     * Create a select range field.
282
     *
283
     * @param  string  $name
284
     * @param  string  $begin
285
     * @param  string  $end
286
     * @param  string  $selected
287
     * @param  array   $attributes
288
     *
289
     * @return \Arcanedev\Html\Elements\Select
290
     */
291
    public function selectRange(string $name, $begin, $end, $selected = null, array $attributes = []): Select;
292
293
    /**
294
     * Create a select year field.
295
     *
296
     * @param  string  $name
297
     * @param  string  $begin
298
     * @param  string  $end
299
     * @param  string  $selected
300
     * @param  array   $attributes
301
     *
302
     * @return \Arcanedev\Html\Elements\Select
303
     */
304
    public function selectYear(string $name, $begin, $end, $selected = null, array $attributes = []): Select;
305
306
    /**
307
     * Create a select month field.
308
     *
309
     * @param  string  $name
310
     * @param  string  $selected
311
     * @param  array   $attributes
312
     * @param  string  $format
313
     *
314
     * @return \Arcanedev\Html\Elements\Select
315
     */
316
    public function selectMonth(string $name, $selected = null, array $attributes = [], $format = '%B'): Select;
317
318
    /**
319
     * Create a checkbox input field.
320
     *
321
     * @param  string     $name
322
     * @param  mixed      $value
323
     * @param  bool|null  $checked
324
     * @param  array      $attributes
325
     *
326
     * @return \Arcanedev\Html\Elements\Input
327
     */
328
    public function checkbox(string $name, $value = 1, $checked = null, array $attributes = []): Input;
329
330
    /**
331
     * Create a radio button input field.
332
     *
333
     * @param  string  $name
334
     * @param  mixed   $value
335
     * @param  bool    $checked
336
     * @param  array   $attributes
337
     *
338
     * @return \Arcanedev\Html\Elements\Input
339
     */
340
    public function radio(string $name, $value = null, $checked = null, array $attributes = []): Input;
341
342
    /**
343
     * Create a HTML reset input element.
344
     *
345
     * @param  string  $value
346
     * @param  array   $attributes
347
     *
348
     * @return \Arcanedev\Html\Elements\Button
349
     */
350
    public function reset($value, array $attributes = []): Button;
351
352
    /**
353
     * Create a HTML image input element.
354
     *
355
     * @param  string       $url
356
     * @param  string|null  $name
357
     * @param  array        $attributes
358
     *
359
     * @return \Arcanedev\Html\Elements\Input
360
     */
361
    public function image(string $url, $name = null, array $attributes = []): Input;
362
363
    /**
364
     * Create a submit button element.
365
     *
366
     * @param  string  $value
367
     * @param  array   $attributes
368
     *
369
     * @return \Arcanedev\Html\Elements\Button
370
     */
371
    public function submit($value = null, array $attributes = []): Button;
372
373
    /**
374
     * Create a button element.
375
     *
376
     * @param  string  $value
377
     * @param  array   $attributes
378
     *
379
     * @return \Arcanedev\Html\Elements\Button
380
     */
381
    public function button($value = null, array $attributes = []): Button;
382
383
    /**
384
     * Create a color input field.
385
     *
386
     * @param  string  $name
387
     * @param  string  $value
388
     * @param  array   $attributes
389
     *
390
     * @return \Arcanedev\Html\Elements\Input
391
     */
392
    public function color(string $name, $value = null, array $attributes = []): Input;
393
394
    /**
395
     * Get a value from the session's old input.
396
     *
397
     * @param  string  $name
398
     *
399
     * @return mixed
400
     */
401
    public function old(string $name);
402
}
403