diff --git a/examples/simple.json b/examples/simple.json index ce30e9c..fd08bf5 100644 --- a/examples/simple.json +++ b/examples/simple.json @@ -11,6 +11,7 @@ "perPage": "5", "currentPage": "1", "showActionColumn": true, + "filter": true, "total": 10, "paginationPrefix": "/page", "params": {"class": "table table-bordered", "border": "1"} diff --git a/src/Filter.php b/src/Filter.php new file mode 100644 index 0000000..6b4c0d6 --- /dev/null +++ b/src/Filter.php @@ -0,0 +1,47 @@ +columnsForFilter = $columns; + $this->baseUrl = $baseUrl; + } + + public function create(): void + { + $this->html = str_replace('{action_link}', $this->baseUrl, $this->getTemplate()); + $this->html = str_replace('{column}', 'id', $this->html); + } + + public function render(): void + { + echo $this->html; + } + + public function fetch(): string + { + return $this->html; + } + + public function getColumnsForFilter(): array + { + return $this->columnsForFilter; + } + + public function getTemplate(): string + { + return ''; + } +} \ No newline at end of file diff --git a/src/ListJsonTable.php b/src/ListJsonTable.php index e3a050c..9c75051 100644 --- a/src/ListJsonTable.php +++ b/src/ListJsonTable.php @@ -26,6 +26,7 @@ class ListJsonTable private bool $pagination = true; private bool $showActionColumn = true; + private bool $filter = true; private array $actionsArray = []; private array $customActionsArray = []; @@ -39,6 +40,7 @@ class ListJsonTable $this->baseUrl = $this->data['meta']['baseUrl'] ?? ''; $this->pagination = $this->data['meta']['pagination'] ?? true; $this->showActionColumn = $this->data['meta']['showActionColumn'] ?? true; + $this->filter = $this->data['meta']['filter'] ?? true; $this->beforePrintHook = function () { }; $this->afterPrintHook = function () { @@ -86,6 +88,10 @@ class ListJsonTable { if ($this->data['data']) { +// if($this->filter) +// { +// +// } $this->count = $this->data["meta"]["perPage"] * ($this->data['meta']["currentPage"] - 1); foreach ($this->data['data'] as $row) { $this->html .= "