Skip to content

Commit 6a0f312

Browse files
authored
add the ability to omit the search argument in the CollectionEngine (#515)
1 parent 97aef55 commit 6a0f312

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Engines/CollectionEngine.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ protected function searchModels(Builder $builder)
117117
return false;
118118
}
119119

120+
if (! $builder->query) {
121+
return true;
122+
}
123+
120124
foreach ($columns as $column) {
121125
$attribute = $model->{$column};
122126

tests/Feature/CollectionEngineTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ protected function defineDatabaseMigrations()
3838
]);
3939
}
4040

41+
public function test_it_can_retrieve_results_with_empty_search()
42+
{
43+
$models = SearchableUserModel::search()->get();
44+
45+
$this->assertCount(2, $models);
46+
}
47+
4148
public function test_it_can_retrieve_results()
4249
{
4350
$models = SearchableUserModel::search('Taylor')->where('email', 'taylor@laravel.com')->get();

0 commit comments

Comments
 (0)