Skip to content

Commit

Permalink
Add fillPageItems
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 authored Oct 10, 2024
1 parent f965cfe commit 70da2eb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Layout/Concerns/WithScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ trait WithScroll
public function mountWithScroll(): void
{
if (blank($this->models)) {
$range = range(1, $this->getScrollLimit());

foreach ($range as $page) {
$this->mergePageItems($this->getPageItems($page)->all());

Sleep::for(100)->milliseconds();
}
$this->fillPageItems();
}
}

Expand Down Expand Up @@ -73,6 +67,17 @@ protected function getPageItems(?int $page = null): LengthAwarePaginator
->paginate(perPage: 16, page: $page);
}

protected function fillPageItems(): void
{
$range = range(1, $this->getScrollLimit());

foreach ($range as $page) {
$this->mergePageItems($this->getPageItems($page)->all());

Sleep::for(100)->milliseconds();
}
}

protected function mergePageItems(array $models = []): void
{
$this->models = array_merge_recursive($this->models, $models);
Expand Down

0 comments on commit 70da2eb

Please sign in to comment.