diff options
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 ?? []), + ]); + } +} |
