Inline edit for v2

This commit is contained in:
James Cole
2024-02-10 08:28:59 +01:00
parent d0844356cb
commit 723aa65e7a
14 changed files with 517 additions and 28 deletions

View File

@@ -50,6 +50,9 @@ trait CollectorProperties
private array $postFilters;
private HasMany $query;
private array $stringFields;
private ?int $startRow;
private ?int $endRow;
/*
* This array is used to collect ALL tags the user may search for (using 'setTags').
* This way the user can call 'setTags' multiple times and get a joined result.

View File

@@ -67,6 +67,8 @@ class GroupCollector implements GroupCollectorInterface
$this->userGroup = null;
$this->limit = null;
$this->page = null;
$this->startRow = null;
$this->endRow = null;
$this->hasAccountInfo = false;
$this->hasCatInformation = false;
@@ -473,6 +475,10 @@ class GroupCollector implements GroupCollectorInterface
return $collection->slice($offset, $this->limit);
}
// OR filter the array according to the start and end row variable
if (null !== $this->startRow && null !== $this->endRow) {
return $collection->slice((int)$this->startRow, (int)$this->endRow);
}
return $collection;
}
@@ -486,6 +492,10 @@ class GroupCollector implements GroupCollectorInterface
if (0 === $this->limit) {
$this->setLimit(50);
}
if(null !== $this->startRow && null !== $this->endRow) {
$total = (int)($this->endRow - $this->startRow);
return new LengthAwarePaginator($set, $this->total, $total, 1);
}
return new LengthAwarePaginator($set, $this->total, $this->limit, $this->page);
}
@@ -1055,4 +1065,18 @@ class GroupCollector implements GroupCollectorInterface
->orderBy('transaction_journals.description', 'DESC')
->orderBy('source.amount', 'DESC');
}
public function setEndRow(int $endRow): self
{
$this->endRow = $endRow;
return $this;
}
public function setStartRow(int $startRow): self
{
$this->startRow = $startRow;
return $this;
}
}

View File

@@ -526,6 +526,16 @@ interface GroupCollectorInterface
*/
public function setPage(int $page): self;
/**
* Set the page to get.
*/
public function setStartRow(int $startRow): self;
/**
* Set the page to get.
*/
public function setEndRow(int $endRow): self;
/**
* Set the start and end time of the results to return.
*/