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/TableComponent.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/TableComponent.php') 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() -- cgit v1.2.3