Skip to content

Commit

Permalink
Add Scout 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatseykanets committed Nov 15, 2018
1 parent c2e3f84 commit c86f29c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [4.0.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v4.0.0) - 2018-11-15

### Added

- Added support for Scout 6

## [3.1.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v3.1.0) - 2018-10-20

### Added
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie
## Contents

- [Installation](#installation)
- [Scout 5](#scout-5)
- [Scout 4](#scout-4)
- [Scout 2, 3](#scout-2-3)
- [Scout 1](#scout-1)
- [Laravel](#laravel)
- [Lumen](#lumen)
- [Configuration](#configuration)
Expand All @@ -36,25 +32,31 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie

You can install the package via composer:

### Scout 5
**Scout 6**

``` bash
composer require pmatseykanets/laravel-scout-postgres
```

### Scout 4
**Scout 5**

``` bash
composer require pmatseykanets/laravel-scout-postgres:3.1.0
```

**Scout 4**

``` bash
composer require pmatseykanets/laravel-scout-postgres:2.3.0
```

### Scout 2, 3
**Scout 2, 3**

``` bash
composer require pmatseykanets/laravel-scout-postgres:1.0.0
```

### Scout 1
**Scout 1**

``` bash
composer require pmatseykanets/laravel-scout-postgres:0.2.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"illuminate/contracts": "~5.4",
"illuminate/database": "~5.4",
"illuminate/support": "~5.4",
"laravel/scout": "~5.0"
"laravel/scout": "~6.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
Expand Down
19 changes: 19 additions & 0 deletions src/PostgresEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,23 @@ protected function usesSoftDeletes(Model $model)
{
return method_exists($model, 'getDeletedAtColumn');
}

/**
* Flush all of the model's records from the engine.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public function flush($model)
{
if (! $this->shouldMaintainIndex($model)) {
return;
}

$indexColumn = $this->getIndexColumn($model);

$this->database
->table($model->searchableAs())
->update([$indexColumn => null]);
}
}
25 changes: 21 additions & 4 deletions tests/PostgresEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,32 @@ public function test_delete_do_nothing_if_index_maintenance_turned_off_globally(
{
list($engine, $db) = $this->getEngine(['maintain_index' => false]);

$db->shouldNotReceive('table');

$engine->delete(Collection::make([new TestModel()]));
}

public function test_flush_removes_all_objects_from_index()
{
list($engine, $db) = $this->getEngine();

$db->shouldReceive('table')
->once()
->andReturn($table = Mockery::mock('stdClass'));
$table->shouldReceive('whereIn')
->with('id', [1])
->andReturnSelf();
$table->shouldReceive('update')
->once()
->with(['searchable' => null]);

$engine->delete(Collection::make([new TestModel()]));
$engine->flush(new TestModel());
}

public function test_flush_does_nothing_if_index_maintenance_turned_off_globally()
{
list($engine, $db) = $this->getEngine(['maintain_index' => false]);

$db->shouldNotReceive('table');

$engine->flush(new TestModel());
}

public function test_search()
Expand Down

0 comments on commit c86f29c

Please sign in to comment.