From 39931b257bb952c4731b481e0a222b39510381b4 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Thu, 1 Aug 2024 12:50:16 +0300 Subject: [PATCH] filter beta0.2 --- src/Filter.php | 3 ++- src/ListJsonTable.php | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Filter.php b/src/Filter.php index 6b4c0d6..2843862 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -4,7 +4,8 @@ namespace Itguild\Tables; class Filter { - private array $columnsForFilter; +// private array $columnsForFilter; +private string $column; private string $html = ""; private string $baseUrl; diff --git a/src/ListJsonTable.php b/src/ListJsonTable.php index 9c75051..620160d 100644 --- a/src/ListJsonTable.php +++ b/src/ListJsonTable.php @@ -90,7 +90,17 @@ class ListJsonTable // if($this->filter) // { +// foreach ($this->data['meta']['columns'] as $col) { +// $this->html .= ""; +// foreach ($this->data['meta']['filters'] as $filter) { +// if ($this->issetFilter($filter)) +// { +// $filters = new Filter($filter, ) +// } +// } // +// +// } // } $this->count = $this->data["meta"]["perPage"] * ($this->data['meta']["currentPage"] - 1); foreach ($this->data['data'] as $row) { @@ -110,14 +120,7 @@ class ListJsonTable } $this->getCustomColumns($row["id"] ?? null); -// if (isset($col['id'])) { -// $newColumn = $this->getColumns($col['id']); -// -// $this->html .= "$newColumn"; -// } -// else { -// $this->html .= ""; -// } + if ($this->showActionColumn) { if (isset($row["id"])) { $actions = $this->getActions($row["id"]); @@ -189,6 +192,18 @@ class ListJsonTable return false; } + private function issetFilter($filter): bool + { + if (isset($this->data['meta']['filter'])) { + foreach ($this->data['meta']['filter'] as $key => $currentFilter) { + if ($key === $filter) { + return true; + } + } + } + return false; + } + private function is_fillable($column): bool { if (isset($this->data['meta']['fillable'])) {