diff options
Diffstat (limited to 'src/Columns/Column.php')
-rw-r--r-- | src/Columns/Column.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Columns/Column.php b/src/Columns/Column.php index 46a03ba..ad3a787 100644 --- a/src/Columns/Column.php +++ b/src/Columns/Column.php @@ -15,6 +15,10 @@ use Closure; class Column { use Makable; + + /** + * @var TableComponent<Model> + */ private TableComponent $table; private bool $showInSelect; private bool $shouldEscape = true; @@ -32,6 +36,10 @@ class Column { $this->showInSelect = $this->title !== null; } + /** + * @template TModel of Model + * @param TableComponent<TModel> $table + */ public function setTable(TableComponent $table): void { $this->table = $table; @@ -55,7 +63,9 @@ class Column { public function sortable(?callable $fn): static { - $this->sortFn = $fn; + if ($fn !== null) { + $this->sortFn = Closure::fromCallable($fn); + } return $this; } @@ -64,7 +74,11 @@ class Column { return $this->sortFn !== null; } - public function applySort(Builder $query, string $dir): void + /** + * @template TModel of Model + * @param Builder<TModel> $query + */ + public function applySort(Builder $query, ?string $dir): void { if ($this->sortFn !== null) { ($this->sortFn)($query, $dir); @@ -88,7 +102,7 @@ class Column { return $this; } - public function showInSelect($show = true): static + public function showInSelect(bool $show = true): static { $this->showInSelect = $show; return $this; |