summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/views/toolbar/select-filter.blade.php1
-rw-r--r--src/Concerns/WithAttributes.php22
-rw-r--r--src/Toolbar/SelectFilter.php5
3 files changed, 28 insertions, 0 deletions
diff --git a/resources/views/toolbar/select-filter.blade.php b/resources/views/toolbar/select-filter.blade.php
index 9810ed9..20a77a6 100644
--- a/resources/views/toolbar/select-filter.blade.php
+++ b/resources/views/toolbar/select-filter.blade.php
@@ -8,6 +8,7 @@
id="{{ $id }}"
class="form-select"
wire:model.live="filters.{{ $key }}"
+ {{ $attributes }}
>
@if (!empty($placeholder))
<option value="">
diff --git a/src/Concerns/WithAttributes.php b/src/Concerns/WithAttributes.php
new file mode 100644
index 0000000..5b77fa5
--- /dev/null
+++ b/src/Concerns/WithAttributes.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Lightscale\LaralightTables\Concerns;
+
+use Illuminate\View\ComponentAttributeBag;
+
+trait WithAttributes
+{
+ protected ?array $attributes = null;
+
+ public function attributes(array $attributes): static
+ {
+ $this->attributes = $attributes;
+ return $this;
+ }
+
+ protected function getAttributes(): ComponentAttributeBag
+ {
+ return new ComponentAttributeBag($this->attributes ?? []);
+ }
+
+}
diff --git a/src/Toolbar/SelectFilter.php b/src/Toolbar/SelectFilter.php
index 0549885..aa1c21a 100644
--- a/src/Toolbar/SelectFilter.php
+++ b/src/Toolbar/SelectFilter.php
@@ -2,10 +2,14 @@
namespace Lightscale\LaralightTables\Toolbar;
+use Lightscale\LaralightTables\Concerns\WithAttributes;
+
use Illuminate\View\View;
class SelectFilter extends Filter
{
+ use WithAttributes;
+
protected iterable $options;
protected ?string $placeholder = null;
@@ -29,6 +33,7 @@ class SelectFilter extends Filter
'label' => $this->label,
'options' => $this->options,
'placeholder' => $this->placeholder,
+ 'attributes' => $this->getAttributes(),
]);
}