-
Notifications
You must be signed in to change notification settings - Fork 554
/
Files.php
39 lines (34 loc) · 1.06 KB
/
Files.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace A17\Twill\View\Components\Fields;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Str;
class Files extends TwillFormComponent
{
public function __construct(
string $name,
string $label,
bool $renderForBlocks = false,
bool $renderForModal = false,
string $note = null,
// Component specific
public int $max = 1,
public int $filesizeMax = 0,
public bool $buttonOnTop = false,
public ?string $itemLabel = null,
public ?string $fieldNote = null,
) {
$itemLabel = $itemLabel ?? strtolower($label);
$this->itemLabel = $itemLabel;
parent::__construct(
name: $name,
label: $label,
note: $note ?? 'Add' . ($max > 1 ? " up to $max $itemLabel" : ' one ' . Str::singular($itemLabel)),
renderForBlocks: $renderForBlocks,
renderForModal: $renderForModal
);
}
public function render(): View
{
return view('twill::partials.form._files', $this->data());
}
}