-
Notifications
You must be signed in to change notification settings - Fork 554
/
Repeater.php
41 lines (36 loc) · 1.23 KB
/
Repeater.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
40
41
<?php
namespace A17\Twill\View\Components\Fields;
use Illuminate\Contracts\View\View;
class Repeater extends TwillFormComponent
{
public function __construct(
// Component specific
public string $type,
public bool $buttonAsLink = false,
public bool $reorder = true,
public ?int $max = null,
public bool $allowCreate = true,
public ?string $relation = null,
public ?array $browserModule = null,
// Generic
bool $renderForBlocks = false,
bool $renderForModal = false,
?string $label = null,
?string $name = null,
) {
parent::__construct(
name: $name ?? $type,
label: $label ?? $type,
renderForBlocks: $renderForBlocks,
renderForModal: $renderForModal,
);
$this->browserModule = $browserModule ? [
'label' => $browserModule['label'] ?? ucfirst($browserModule['name']),
'value' => moduleRoute($browserModule['name'], $browserModule['routePrefix'] ?? null, 'browser', $browserModule['params'] ?? [], false)
] : null;
}
public function render(): View
{
return view('twill::partials.form._repeater', $this->data());
}
}