diff options
| author | Sam Light <samlight1994@gmail.com> | 2026-02-12 00:23:02 +0000 |
|---|---|---|
| committer | Sam Light <samlight1994@gmail.com> | 2026-02-12 00:23:02 +0000 |
| commit | 536fa6c917d63b14feeb8f876e6a1d62acb577fc (patch) | |
| tree | 548f6b23324c8a0ef9448d16773ffad33ccc9c0b /src/Toolbar/Button.php | |
| parent | f998df6a2abaa211a730f247ce814f238228fb70 (diff) | |
Created new dropdown toolbar itemv2.1.0
Diffstat (limited to 'src/Toolbar/Button.php')
| -rw-r--r-- | src/Toolbar/Button.php | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/src/Toolbar/Button.php b/src/Toolbar/Button.php index 92b041f..1ac686a 100644 --- a/src/Toolbar/Button.php +++ b/src/Toolbar/Button.php @@ -4,38 +4,16 @@ declare(strict_types=1); namespace Lightscale\LaralightTables\Toolbar; -use Illuminate\View\ComponentAttributeBag; use Illuminate\View\View; -use Lightscale\LaralightTables\Concerns\WithAttributes; +use Lightscale\LaralightTables\Toolbar\Concerns\WithAction; +use Lightscale\LaralightTables\Toolbar\Concerns\WithAttributes; +use Lightscale\LaralightTables\Toolbar\Concerns\WithSlot; class Button extends Item { + use WithAction; 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, - ]); - } + use WithSlot; public function render(): View { @@ -43,7 +21,9 @@ class Button extends Item 'laralight-tables::toolbar.button', [ 'action' => $this->action, - 'attributes' => $this->makeAttributes(), + 'attributes' => $this->getAttributes([ + 'wire:click' => $this->action, + ]), 'slot' => $this->slot, ] ); |
