summaryrefslogtreecommitdiff
path: root/src/TableComponent.php
diff options
context:
space:
mode:
authorSam Light <samlight1994@gmail.com>2024-12-27 23:04:40 +0000
committerSam Light <samlight1994@gmail.com>2024-12-27 23:04:40 +0000
commitb19d30c7ad5a041ccc42ca9542150c7b371fe4fe (patch)
treefcdba3b9681cef60e0e774e08c377d03c5d1defb /src/TableComponent.php
parent3c33b9201ee02d8b73986e489b9637d2875413de (diff)
Lots of updates
Diffstat (limited to 'src/TableComponent.php')
-rw-r--r--src/TableComponent.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/TableComponent.php b/src/TableComponent.php
index 04d457e..da31a90 100644
--- a/src/TableComponent.php
+++ b/src/TableComponent.php
@@ -4,6 +4,7 @@ namespace Lightscale\LaralightTables;
use Livewire\Component;
use Livewire\WithPagination;
+use Livewire\Attributes\Url;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Str;
@@ -28,6 +29,8 @@ abstract class TableComponent extends Component
// Properties
public string $search = '';
+
+ #[Url]
public int $pageSize = 0;
public array $activeColumns = [];
@@ -72,17 +75,17 @@ abstract class TableComponent extends Component
return $query;
}
+ private $columnsCache = null;
+
protected function getColumns()
{
- static $columns = null;
-
- if($columns === null) {
- $columns = collect($this->columns())->each(
+ if($this->columnsCache === null) {
+ $this->columnsCache = collect($this->columns())->each(
fn($c) => $c->setTable($this)
);
}
- return $columns;
+ return $this->columnsCache;
}
public function render()