summaryrefslogtreecommitdiff
path: root/src/Columns/Column.php
diff options
context:
space:
mode:
authorSam Light <samlight1994@gmail.com>2025-04-26 13:05:25 +0100
committerSam Light <samlight1994@gmail.com>2025-04-26 13:05:25 +0100
commit6d26688fded015141a45a88b90b2d70a0ac88420 (patch)
tree33324531f6e9595c7eb190b89bcdb5a7b55d1b5f /src/Columns/Column.php
parent88f71aeba1a1649661d713297d3a75454636b2d1 (diff)
Larastanning
Diffstat (limited to 'src/Columns/Column.php')
-rw-r--r--src/Columns/Column.php20
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;