From 438d50fe48182fe25a273518b3de0c4cd655b141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20M=2E?= Date: Fri, 18 Oct 2024 21:52:47 +0200 Subject: [PATCH] Allow Scout builder --- src/Layout/Concerns/WithScroll.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Layout/Concerns/WithScroll.php b/src/Layout/Concerns/WithScroll.php index 0884d84..bc11350 100644 --- a/src/Layout/Concerns/WithScroll.php +++ b/src/Layout/Concerns/WithScroll.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; +use Laravel\Scout\Scout; use Livewire\Attributes\Computed; use Livewire\Attributes\Locked; use Livewire\WithPagination; @@ -18,7 +19,10 @@ trait WithScroll public function bootWithScroll(): void { - throw_if(! method_exists($this, 'getBuilder') || ! $this->getBuilder() instanceof Builder); + throw_if( + ! method_exists($this, 'getBuilder') || + ! ($this->getBuilder() instanceof Builder || ! $this->getBuilder() instanceof Scout) + ); data_set($this, 'models', collect(), false); } @@ -40,7 +44,7 @@ public function fetch(): void { $page = $this->getScrollPage(); - $limit = $this->getScrollPageLimit(); + $limit = $this->getScrollPageLimit(); if (! $this->hasMorePages() || (is_numeric($limit) && $page > $limit)) { return; @@ -93,7 +97,7 @@ protected function fillScrollItems(?int $page = null): void $pages = $this->getScrollPages($page); - $limit = $this->getScrollPageLimit(); + $limit = $this->getScrollPageLimit(); $pages->each(function (int $page) use ($builder, $limit) { if (! $this->hasMorePages() || (is_numeric($limit) && $page > $limit)) {