blob: 92b041fc94773940818728942251614846015c29 (
plain)
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
42
43
44
45
46
47
48
49
50
51
|
<?php
declare(strict_types=1);
namespace Lightscale\LaralightTables\Toolbar;
use Illuminate\View\ComponentAttributeBag;
use Illuminate\View\View;
use Lightscale\LaralightTables\Concerns\WithAttributes;
class Button extends Item
{
use WithAttributes;
private ?string $action = null;
private string $slot = '';
public function action(string $action): static
{
$this->action = $action;
return $this;
}
public function slot(string $slot): static
{
$this->slot = $slot;
return $this;
}
private function makeAttributes(): ComponentAttributeBag
{
return $this->getAttributes()->merge([
'wire:click' => $this->action,
]);
}
public function render(): View
{
return view(
'laralight-tables::toolbar.button',
[
'action' => $this->action,
'attributes' => $this->makeAttributes(),
'slot' => $this->slot,
]
);
}
}
|