diff --git a/src/JasonTable.php b/src/JasonTable.php index 276891b..bef4652 100644 --- a/src/JasonTable.php +++ b/src/JasonTable.php @@ -20,7 +20,7 @@ class JasonTable $this->beforePrintCell = $closure; } - public function getCustomCell(string $key, string $cell) + public function getCustomCell(string $key, string|null $cell) { if (is_array($this->beforePrintCell)) { foreach ($this->beforePrintCell as $currentKey => $closure) { diff --git a/src/ListJsonTable.php b/src/ListJsonTable.php index 26c7742..9f374b2 100644 --- a/src/ListJsonTable.php +++ b/src/ListJsonTable.php @@ -29,7 +29,7 @@ class ListJsonTable extends JasonTable #[NoReturn] public function __construct(string $json) { - $this->beforePrintCell = false; + $this->beforePrintCell = []; $this->json = $json; $this->data = json_decode($this->json, true); $this->baseUrl = $this->data['meta']['baseUrl'] ?? ''; @@ -86,7 +86,7 @@ class ListJsonTable extends JasonTable } foreach ($row as $key => $cell) { if ($this->issetColumn($key) and $this->is_fillable($key)) { - if($this->beforePrintCell and $cell !== null) { + if($this->beforePrintCell) { $cell = $this->getCustomCell($key, $cell); } $this->html .= "" . $cell . ""; diff --git a/src/ViewJsonTable.php b/src/ViewJsonTable.php index 181d699..ab051c0 100644 --- a/src/ViewJsonTable.php +++ b/src/ViewJsonTable.php @@ -39,7 +39,7 @@ class ViewJsonTable extends JasonTable { foreach ($this->data['meta']['rows'] as $key => $row){ if ($this->issetRow($key)){ - if ($this->beforePrintCell and $this->dataJson[$key] !== null) { + if ($this->beforePrintCell) { $this->dataJson[$key] = $this->getCustomCell($key, $this->dataJson[$key]); } $this->html .= "" . $row . "" . $this->dataJson[$key] . "";