Skip to content

Commit 8ba1679

Browse files
committed
Last few edits
1 parent 8bd1650 commit 8ba1679

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/Eloquent/Builder.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,8 @@ public function getQuery(): QueryBuilder
524524
*
525525
* @throws MissingOrderException|BindingResolutionException
526526
*/
527-
public function cursorPaginate(
528-
$perPage = null,
529-
$columns = ['*'],
530-
$cursorName = 'cursor',
531-
$cursor = null
532-
): CursorPaginator {
527+
public function cursorPaginate($perPage = null, $columns = ['*'], $cursorName = 'cursor', $cursor = null): SearchAfterPaginator
528+
{
533529
if (empty($this->query->orders)) {
534530
//try set created_at & updated_at
535531
if (! $this->inferSort()) {

src/Eloquent/Docs/ModelDocs.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
use Illuminate\Contracts\Database\Query\Expression;
99
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
1010
use Illuminate\Pagination\Cursor;
11-
use Illuminate\Pagination\CursorPaginator;
1211
use PDPhilip\Elasticsearch\Collection\ElasticCollection;
1312
use PDPhilip\Elasticsearch\Eloquent\Model;
13+
use PDPhilip\Elasticsearch\Pagination\SearchAfterPaginator;
14+
use PDPhilip\Elasticsearch\Query\Builder;
1415

1516
/**
1617
* @method static $this term(string $term, $boostFactor = null)
@@ -72,19 +73,17 @@
7273
* @method static array getIndexSettings()
7374
* @method static bool indexExists()
7475
* @method static LengthAwarePaginator paginate(int $perPage = 15, array $columns = ['*'], string $pageName = 'page', ?int $page = null, ?int $total = null)
75-
* @method static CursorPaginator cursorPaginate(int|null $perPage = null, array $columns = [], string $cursorName = 'cursor', ?Cursor $cursor = null)
76+
* @method static SearchAfterPaginator cursorPaginate(int|null $perPage = null, array $columns = [], string $cursorName = 'cursor', ?Cursor $cursor = null)
7677
* @method static string getQualifiedKeyName()
7778
* @method static string getConnection()
7879
* @method static void truncate()
79-
* @method static ElasticCollection insert($values, $returnData = null)
80+
* @method static ElasticCollection insert($values, $returnData = null):
8081
* @method static ElasticCollection insertWithoutRefresh($values, $returnData = null)
8182
*
8283
* @property object $search_highlights
8384
* @property object $with_highlights
8485
* @property array $search_highlights_as_array
8586
*
86-
* @mixin \Illuminate\Database\Query\Builder
87+
* @mixin Builder
8788
*/
88-
trait ModelDocs
89-
{
90-
}
89+
trait ModelDocs {}

src/Pagination/SearchAfterPaginator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
use Illuminate\Pagination\Cursor;
88
use Illuminate\Pagination\CursorPaginator;
99
use Illuminate\Support\Collection;
10+
use PDPhilip\Elasticsearch\Eloquent\Model;
1011

1112
class SearchAfterPaginator extends CursorPaginator
1213
{
1314
/**
14-
* @param \PDPhilip\Elasticsearch\Eloquent\Model $item
15+
* @param Model $item
1516
*/
1617
public function getParametersForItem($item): array
1718
{
@@ -56,19 +57,18 @@ public function showingFrom(): int
5657
{
5758
$perPage = $this->perPage();
5859
$currentPage = $this->currentPageNumber();
59-
$start = ($currentPage - 1) * $perPage + 1;
6060

61-
return $start;
61+
return ($currentPage - 1) * $perPage + 1;
62+
6263
}
6364

6465
public function showingTo(): int
6566
{
6667
$records = count($this->items);
6768
$currentPage = $this->currentPageNumber();
6869
$perPage = $this->perPage();
69-
$end = (($currentPage - 1) * $perPage) + $records;
7070

71-
return $end;
71+
return (($currentPage - 1) * $perPage) + $records;
7272
}
7373

7474
public function lastPage(): int

0 commit comments

Comments
 (0)