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/Concerns/WithAttributes.php | |
| parent | f998df6a2abaa211a730f247ce814f238228fb70 (diff) | |
Created new dropdown toolbar itemv2.1.0
Diffstat (limited to 'src/Toolbar/Concerns/WithAttributes.php')
| -rw-r--r-- | src/Toolbar/Concerns/WithAttributes.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Toolbar/Concerns/WithAttributes.php b/src/Toolbar/Concerns/WithAttributes.php new file mode 100644 index 0000000..3a37282 --- /dev/null +++ b/src/Toolbar/Concerns/WithAttributes.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +namespace Lightscale\LaralightTables\Toolbar\Concerns; + +use Illuminate\View\ComponentAttributeBag; + +trait WithAttributes +{ + /** + * @var array<string, string> + */ + protected ?array $attributes = null; + + /** + * @param array<string, string> $attributes + */ + public function attributes(array $attributes): static + { + $this->attributes = $attributes; + + return $this; + } + + /** + * @param array<string, string|null> $merge + */ + protected function getAttributes(array $merge = []): ComponentAttributeBag + { + return new ComponentAttributeBag([ + ...$merge, + ...($this->attributes ?? []), + ]); + } +} |
