Skip to content

Commit 0c6de03

Browse files
committed
Feat: Make paginatedData an accessible computed property
1 parent 2bb7374 commit 0c6de03

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require-dev": {
2626
"laravel/pint": "^1.7",
2727
"orchestra/testbench": "^9.0",
28-
"phpunit/phpunit": "^9.0"
28+
"phpunit/phpunit": "^11.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

src/WireTable.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace WireTable;
44

55
use Illuminate\Contracts\Database\Query\Builder;
6+
use Illuminate\Contracts\Pagination\Paginator;
67
use Illuminate\Contracts\View\View;
8+
use Livewire\Attributes\Computed;
79
use Livewire\Attributes\On;
810
use Livewire\Component;
911
use WireTable\Data\Column;
@@ -43,7 +45,13 @@ public function renderTable(): View
4345
return view('wire-table::layout')->with($this->layoutData());
4446
}
4547

46-
protected function layoutData(): array
48+
#[On('wiretable:reload')]
49+
public function reload()
50+
{
51+
}
52+
53+
#[Computed]
54+
public function paginatedData(): Paginator
4755
{
4856
$query = $this->query();
4957
$query = $this->filter($query);
@@ -52,21 +60,18 @@ protected function layoutData(): array
5260
$query = $this->applySorting($query);
5361
}
5462

55-
$paginator = $this->paginator($query);
63+
return $this->paginator($query);
64+
}
5665

66+
protected function layoutData(): array
67+
{
5768
return [
58-
'paginator' => $paginator,
69+
'paginator' => $this->paginatedData,
5970
'theme' => $this->theme(),
6071
'iconTheme' => $this->iconTheme(),
6172
];
6273
}
6374

64-
#[On('wiretable:reload')]
65-
public function reload()
66-
{
67-
68-
}
69-
7075
protected function theme(): string
7176
{
7277
$theme = $this->theme ?? config('wire-table.theme');

0 commit comments

Comments
 (0)