From b19d30c7ad5a041ccc42ca9542150c7b371fe4fe Mon Sep 17 00:00:00 2001 From: Sam Light Date: Fri, 27 Dec 2024 23:04:40 +0000 Subject: Lots of updates --- src/Columns/ElementColumn.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/Columns/ElementColumn.php (limited to 'src/Columns/ElementColumn.php') diff --git a/src/Columns/ElementColumn.php b/src/Columns/ElementColumn.php new file mode 100644 index 0000000..5ad7c7c --- /dev/null +++ b/src/Columns/ElementColumn.php @@ -0,0 +1,39 @@ +elemAttributesFn = Closure::fromCallable($fn); + return $this; + } + + protected function getElemAttributes(Model $row) : array + { + return $this->elemAttributesFn?->call($this, $row) ?? []; + } + + protected function getContent(Model $row) + { + $content = parent::getContent($row); + $attributes = new ComponentAttributeBag($this->getElemAttributes($row)); + $attributes = $attributes->toHtml(); + + return new HtmlString( + "<{$this->element} {$attributes}>{$content}element}>" + ); + } + +} -- cgit v1.2.3