Skip to content

Commit

Permalink
Allow Scout builder
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 authored Oct 18, 2024
1 parent b014f46 commit 438d50f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Layout/Concerns/WithScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 438d50f

Please sign in to comment.