Skip to content

Commit 0843f85

Browse files
authored
pagination customization
1 parent 4e711cc commit 0843f85

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

readme.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,27 +412,27 @@ Connection and index names in query overrides connection and index names in conf
412412

413413
##### Getting document by id
414414
```php
415-
$documents = ES::type("my_type")->id(3)->get();
415+
ES::type("my_type")->id(3)->first();
416416

417417
# or
418418

419-
$documents = ES::type("my_type")->_id(3)->get();
419+
ES::type("my_type")->_id(3)->first();
420420
```
421421
##### Sorting
422422
```php
423-
$documents = ES::type("my_type")->orderBy("created_at", "desc")->get();
423+
ES::type("my_type")->orderBy("created_at", "desc")->get();
424424

425425
# Sorting with text search score
426426

427-
$documents = ES::type("my_type")->orderBy("_score")->get();
427+
ES::type("my_type")->orderBy("_score")->get();
428428
```
429429
##### Limit and offset
430430
```php
431-
$documents = ES::type("my_type")->take(10)->skip(5)->get();
431+
ES::type("my_type")->take(10)->skip(5)->get();
432432
```
433433
##### Select only specific fields
434434
```php
435-
$documents = ES::type("my_type")->select("title", "content")->take(10)->skip(5)->get();
435+
ES::type("my_type")->select("title", "content")->take(10)->skip(5)->get();
436436
```
437437
##### Where clause
438438
```php
@@ -603,28 +603,55 @@ ES::type("my_type")->scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhc
603603
```php
604604
$documents = ES::type("my_type")->search("bar")->paginate(5);
605605

606-
# getting pagination links
606+
# Getting pagination links
607607

608608
$documents->links();
609609

610+
# Bootstrap 4 pagination
611+
612+
$documents->links("bootstrap-4");
613+
614+
# Simple bootstrap 4 pagination
615+
616+
$documents->links("simple-bootstrap-4");
617+
618+
# Simple pagination
619+
620+
$documents->links("simple-default");
621+
```
622+
623+
These are all pagination methods you may use:
624+
625+
```php
626+
$documents->count()
627+
$documents->currentPage()
628+
$documents->firstItem()
629+
$documents->hasMorePages()
630+
$documents->lastItem()
631+
$documents->lastPage()
632+
$documents->nextPageUrl()
633+
$documents->perPage()
634+
$documents->previousPageUrl()
635+
$documents->total()
636+
$documents->url($page)
610637
```
611638

612639
##### Getting the query array without execution
613640

614641
```php
615-
$query = ES::type("my_type")->search("foo")->where("views", ">", 150)->query();
642+
ES::type("my_type")->search("foo")->where("views", ">", 150)->query();
616643
```
617644

618645
##### Getting the original elasticsearch response
619646

620647
```php
621-
$query = ES::type("my_type")->search("foo")->where("views", ">", 150)->response();
648+
ES::type("my_type")->search("foo")->where("views", ">", 150)->response();
622649
```
623650

624651
##### Ignoring bad HTTP response
625652

626653
```php
627-
$documents = ES::type("my_type")->ignore(404, 500)->id(5)->first();
654+
ES::type("my_type")->ignore(404, 500)->id(5)->first();
628655
```
629656

630657
##### Query Caching (Laravel & Lumen)

0 commit comments

Comments
 (0)