diff options
Diffstat (limited to 'src/Toolbar')
-rw-r--r-- | src/Toolbar/Filter.php | 9 | ||||
-rw-r--r-- | src/Toolbar/Item.php | 4 | ||||
-rw-r--r-- | src/Toolbar/PageSize.php | 3 | ||||
-rw-r--r-- | src/Toolbar/SelectFilter.php | 6 |
4 files changed, 20 insertions, 2 deletions
diff --git a/src/Toolbar/Filter.php b/src/Toolbar/Filter.php index 51e0d9a..f6777ce 100644 --- a/src/Toolbar/Filter.php +++ b/src/Toolbar/Filter.php @@ -2,6 +2,7 @@ namespace Lightscale\LaralightTables\Toolbar; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; use Closure; @@ -26,12 +27,16 @@ abstract class Filter extends Item return "filter_{$this->key}"; } - public function filter(callable $filterCB): static + public function filter(callable $fn): static { - $this->filterCallback = $filterCB; + $this->filterCallback = Closure::fromCallable($fn);; return $this; } + /** + * @template TModel of Model + * @param Builder<TModel> $query + */ public function applyFilter(Builder $query): void { if ($this->filterCallback !== null) { diff --git a/src/Toolbar/Item.php b/src/Toolbar/Item.php index e91698f..e161fb9 100644 --- a/src/Toolbar/Item.php +++ b/src/Toolbar/Item.php @@ -8,6 +8,7 @@ use Lightscale\LaralightTables\Concerns\Makable; use Illuminate\View\View; use Illuminate\Support\HtmlString; +use Illuminate\Database\Eloquent\Model; abstract class Item { @@ -25,6 +26,9 @@ abstract class Item return $this->toolbar; } + /** + * @return TableComponent<Model> + */ public function getTable(): TableComponent { return $this->getToolbar()->getTable(); diff --git a/src/Toolbar/PageSize.php b/src/Toolbar/PageSize.php index 9c2821a..79234a8 100644 --- a/src/Toolbar/PageSize.php +++ b/src/Toolbar/PageSize.php @@ -6,6 +6,9 @@ use Illuminate\View\View; class PageSize extends Item { + /** + * @param array<int> $pageSizes + */ public function __construct( private array $pageSizes = [10, 25, 50], ) {} diff --git a/src/Toolbar/SelectFilter.php b/src/Toolbar/SelectFilter.php index aa1c21a..7adc47a 100644 --- a/src/Toolbar/SelectFilter.php +++ b/src/Toolbar/SelectFilter.php @@ -10,6 +10,9 @@ class SelectFilter extends Filter { use WithAttributes; + /** + * @var iterable<string, string> + */ protected iterable $options; protected ?string $placeholder = null; @@ -19,6 +22,9 @@ class SelectFilter extends Filter return $this; } + /** + * @param iterable<string, string> $options + */ public function options(iterable $options): static { $this->options = $options; |