Skip to content

Commit a4a592e

Browse files
committed
Bugfix
1 parent 5704910 commit a4a592e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
All notable changes to `laravel-cross-eloquent-search` will be documented in this file
44

5-
## 2.0.0 - 2021-01-29
5+
## 2.0.3 - 2021-04-29
6+
7+
- Bugfix for non-paginated queries.
8+
9+
## 2.0.0 / 2.0.1 / 2.0.2 - 2021-01-29
610

711
- Support for the soundex algorithm
812
- Ability to disable wildcards

src/Searcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Searcher
5555
/**
5656
* The query string variable used to store the page.
5757
*/
58-
protected string $pageName = 'page';
58+
protected string $pageName = '';
5959

6060
/**
6161
* Parse the search term into multiple terms.
@@ -410,7 +410,7 @@ protected function getIdAndOrderAttributes()
410410
$paginateMethod = $this->simplePaginate ? 'simplePaginate' : 'paginate';
411411

412412
// get all results or limit the results by pagination
413-
return $this->perPage
413+
return $this->pageName
414414
? $query->{$paginateMethod}($this->perPage, ['*'], $this->pageName, $this->page)
415415
: $query->get();
416416

@@ -509,6 +509,6 @@ public function get(string $terms = null)
509509
return $modelsPerType->get($modelKey)->get($item->$modelKey);
510510
})
511511
->pipe(fn (Collection $models) => new EloquentCollection($models))
512-
->when($this->perPage, fn (EloquentCollection $models) => $results->setCollection($models));
512+
->when($this->pageName, fn (EloquentCollection $models) => $results->setCollection($models));
513513
}
514514
}

tests/SearchTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
66
use Illuminate\Pagination\Paginator;
77
use Illuminate\Support\Carbon;
8+
use Illuminate\Support\Collection;
89
use ProtoneMedia\LaravelCrossEloquentSearch\Search;
910

1011
class SearchTest extends TestCase
@@ -26,6 +27,7 @@ public function it_can_search_two_models_and_orders_by_updated_at_by_default()
2627
->add(Video::class, 'title')
2728
->get('foo');
2829

30+
$this->assertInstanceOf(Collection::class, $results);
2931
$this->assertCount(2, $results);
3032

3133
$this->assertTrue($results->contains($postA));

0 commit comments

Comments
 (0)