diff options
author | Sam Light <samlight1994@gmail.com> | 2025-03-27 10:53:34 +0000 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-03-27 10:53:34 +0000 |
commit | 1f81ce361cb454b1655d6e2a7ac031bc1e3b2ede (patch) | |
tree | 1307ebad02e2a9644613d496e3d3ec87ed2cdfb9 /src/Columns/Column.php | |
parent | 56a180f139699b3ee1eec566b6a98105576f804a (diff) |
Seperating toolbar into its own class and views
Diffstat (limited to 'src/Columns/Column.php')
-rw-r--r-- | src/Columns/Column.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Columns/Column.php b/src/Columns/Column.php index 94e386f..895708f 100644 --- a/src/Columns/Column.php +++ b/src/Columns/Column.php @@ -28,24 +28,24 @@ class Column { $this->showInSelect = $this->title !== null; } - public static function make(string $name, ?string $title = null) : static + public static function make(string $name, ?string $title = null): static { return new static($name, $title); } - public function setTable(TableComponent $table) : void + public function setTable(TableComponent $table): void { $this->table = $table; } - public function getTitle() + public function getTitle(): string { return $this->title; } - private function defaultSlot(Model $row) + private function defaultSlot(Model $row): string { - return $row->{$this->name}; + return (string) $row->{$this->name}; } public function slot(callable $fn) : static @@ -77,22 +77,23 @@ class Column { return $this; } - public function showInSelect($show = true) + public function showInSelect($show = true): static { $this->showInSelect = $show; + return $this; } - public function getShowInSelect() + public function getShowInSelect(): bool { return $this->showInSelect; } - protected function getContent(Model $row) + protected function getContent(Model $row): string { return $this->slotFn?->call($this, $row, $this) ?? $this->defaultSlot($row); } - public function view(Model $row) + public function view(Model $row): HtmlString { $attributes = $this->tdAttributesFn?->call($this, $row) ?? []; $attributes = (new ComponentAttributeBag($attributes))->toHtml(); |