Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/mattkingshott/quest
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
mattkingshott committed Dec 6, 2020
2 parents 95014eb + db69365 commit 2d1d08e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/Macros/WhereFuzzy.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public static function make(Builder $builder, $field, $value) : Builder
}

return $builder
->addSelect(static::pipeline($field, $native, $value))
->orderBy('relevance_' . str_replace('.', '_', $field), 'desc')
->having('relevance_' . str_replace('.', '_', $field), '>', 0);
->addSelect(static::pipeline($field, $native, $value))
->orderBy('relevance_' . str_replace('.', '_', $field), 'desc')
->having('relevance_' . str_replace('.', '_', $field), '>', 0);
}


Expand Down
40 changes: 20 additions & 20 deletions tests/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ protected function setUp() : void
public function it_can_perform_a_fuzzy_search_and_receive_one_result()
{
$results = DB::table('users')
->whereFuzzy('users.name', 'jad')
->get();
->whereFuzzy('users.name', 'jad')
->get();

$this->assertCount(1, $results);
$this->assertEquals('Jane Doe', $results->first()->name);
Expand All @@ -66,8 +66,8 @@ public function it_can_perform_a_fuzzy_search_and_receive_one_result()
public function it_can_perform_a_fuzzy_search_and_receive_multiple_results()
{
$results = DB::table('users')
->whereFuzzy('name', 'jd')
->get();
->whereFuzzy('name', 'jd')
->get();

$this->assertCount(2, $results);
$this->assertEquals('John Doe', $results[0]->name);
Expand All @@ -80,14 +80,14 @@ public function it_can_perform_a_fuzzy_search_and_receive_multiple_results()
public function it_can_perform_a_fuzzy_search_and_paginate_multiple_results()
{
$results = DB::table('users')
->whereFuzzy('name', 'jd')
->simplePaginate(1, ['*'], 'page', 1);
->whereFuzzy('name', 'jd')
->simplePaginate(1, ['*'], 'page', 1);

$this->assertEquals('John Doe', $results->items()[0]->name);

$results = DB::table('users')
->whereFuzzy('name', 'jd')
->simplePaginate(1, ['*'], 'page', 2);
->whereFuzzy('name', 'jd')
->simplePaginate(1, ['*'], 'page', 2);

$this->assertEquals('Jane Doe', $results->items()[0]->name);
}
Expand All @@ -98,9 +98,9 @@ public function it_can_perform_a_fuzzy_search_and_paginate_multiple_results()
public function it_can_perform_a_fuzzy_search_across_multiple_fields()
{
$results = DB::table('users')
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'uk')
->get();
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'uk')
->get();

$this->assertCount(1, $results);
$this->assertEquals('Jane Doe', $results[0]->name);
Expand All @@ -112,10 +112,10 @@ public function it_can_perform_a_fuzzy_search_across_multiple_fields()
public function it_can_order_a_fuzzy_search_by_one_field()
{
$results = DB::table('users')
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'un')
->orderByFuzzy('country')
->get();
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'un')
->orderByFuzzy('country')
->get();

$this->assertCount(2, $results);
$this->assertEquals('John Doe', $results[0]->name);
Expand All @@ -128,10 +128,10 @@ public function it_can_order_a_fuzzy_search_by_one_field()
public function it_can_order_a_fuzzy_search_by_multiple_fields()
{
$results = DB::table('users')
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'un')
->orderByFuzzy(['name', 'country'])
->get();
->whereFuzzy('name', 'jd')
->whereFuzzy('country', 'un')
->orderByFuzzy(['name', 'country'])
->get();

$this->assertCount(2, $results);
$this->assertEquals('John Doe', $results[0]->name);
Expand All @@ -144,7 +144,7 @@ public function it_can_order_a_fuzzy_search_by_multiple_fields()
public function it_can_perform_an_eloquent_fuzzy_search()
{
$results = User::whereFuzzy('name', 'jad')
->get();
->get();

$this->assertCount(1, $results);
$this->assertEquals('Jane Doe', $results->first()->name);
Expand Down

0 comments on commit 2d1d08e

Please sign in to comment.