diff --git a/src/Laravel/src/Pages/Crud/IndexPage.php b/src/Laravel/src/Pages/Crud/IndexPage.php index 069d8307a..e7b3a2157 100644 --- a/src/Laravel/src/Pages/Crud/IndexPage.php +++ b/src/Laravel/src/Pages/Crud/IndexPage.php @@ -236,6 +236,9 @@ protected function getItemsComponent(iterable $items, Fields $fields): Component ->when($this->getResource()->isStickyTable(), function (TableBuilderContract $table): void { $table->sticky(); }) + ->when($this->getResource()->isLazy(), function (TableBuilderContract $table): void { + $table->lazy()->whenAsync(fn (TableBuilderContract $t): TableBuilder => $t->items($this->getResource()->getItems())); + }) ->when($this->getResource()->isColumnSelection(), function (TableBuilderContract $table): void { $table->columnSelection(); }); @@ -251,7 +254,7 @@ protected function getItemsComponents(): array request()->only($this->getResource()->getQueryParamsKeys()) ); - $items = $this->getResource()->getItems(); + $items = $this->getResource()->isLazy() ? [] : $this->getResource()->getItems(); $fields = $this->getResource()->getIndexFields(); return [ diff --git a/src/Laravel/src/Resources/CrudResource.php b/src/Laravel/src/Resources/CrudResource.php index a489c6a1c..be541ad91 100644 --- a/src/Laravel/src/Resources/CrudResource.php +++ b/src/Laravel/src/Resources/CrudResource.php @@ -75,6 +75,8 @@ abstract class CrudResource extends Resource implements CrudResourceContract protected bool $isAsync = true; + protected bool $isLazy = false; + protected bool $isPrecognitive = false; protected bool $deleteRelationships = false; @@ -210,6 +212,11 @@ public function isAsync(): bool return $this->isAsync; } + public function isLazy(): bool + { + return $this->isLazy; + } + public function isPrecognitive(): bool { return $this->isPrecognitive;