Skip to content

Commit c86f29c

Browse files
committed
Add Scout 6 support
1 parent c2e3f84 commit c86f29c

File tree

5 files changed

+57
-13
lines changed

5 files changed

+57
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [4.0.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v4.0.0) - 2018-11-15
4+
5+
### Added
6+
7+
- Added support for Scout 6
8+
39
## [3.1.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v3.1.0) - 2018-10-20
410

511
### Added

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie
1212
## Contents
1313

1414
- [Installation](#installation)
15-
- [Scout 5](#scout-5)
16-
- [Scout 4](#scout-4)
17-
- [Scout 2, 3](#scout-2-3)
18-
- [Scout 1](#scout-1)
1915
- [Laravel](#laravel)
2016
- [Lumen](#lumen)
2117
- [Configuration](#configuration)
@@ -36,25 +32,31 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie
3632

3733
You can install the package via composer:
3834

39-
### Scout 5
35+
**Scout 6**
4036

4137
``` bash
4238
composer require pmatseykanets/laravel-scout-postgres
4339
```
4440

45-
### Scout 4
41+
**Scout 5**
42+
43+
``` bash
44+
composer require pmatseykanets/laravel-scout-postgres:3.1.0
45+
```
46+
47+
**Scout 4**
4648

4749
``` bash
4850
composer require pmatseykanets/laravel-scout-postgres:2.3.0
4951
```
5052

51-
### Scout 2, 3
53+
**Scout 2, 3**
5254

5355
``` bash
5456
composer require pmatseykanets/laravel-scout-postgres:1.0.0
5557
```
5658

57-
### Scout 1
59+
**Scout 1**
5860

5961
``` bash
6062
composer require pmatseykanets/laravel-scout-postgres:0.2.1

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"illuminate/contracts": "~5.4",
2828
"illuminate/database": "~5.4",
2929
"illuminate/support": "~5.4",
30-
"laravel/scout": "~5.0"
30+
"laravel/scout": "~6.0"
3131
},
3232
"require-dev": {
3333
"phpunit/phpunit": "~6.0",

src/PostgresEngine.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,23 @@ protected function usesSoftDeletes(Model $model)
541541
{
542542
return method_exists($model, 'getDeletedAtColumn');
543543
}
544+
545+
/**
546+
* Flush all of the model's records from the engine.
547+
*
548+
* @param \Illuminate\Database\Eloquent\Model $model
549+
* @return void
550+
*/
551+
public function flush($model)
552+
{
553+
if (! $this->shouldMaintainIndex($model)) {
554+
return;
555+
}
556+
557+
$indexColumn = $this->getIndexColumn($model);
558+
559+
$this->database
560+
->table($model->searchableAs())
561+
->update([$indexColumn => null]);
562+
}
544563
}

tests/PostgresEngineTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,32 @@ public function test_delete_do_nothing_if_index_maintenance_turned_off_globally(
7474
{
7575
list($engine, $db) = $this->getEngine(['maintain_index' => false]);
7676

77+
$db->shouldNotReceive('table');
78+
79+
$engine->delete(Collection::make([new TestModel()]));
80+
}
81+
82+
public function test_flush_removes_all_objects_from_index()
83+
{
84+
list($engine, $db) = $this->getEngine();
85+
7786
$db->shouldReceive('table')
87+
->once()
7888
->andReturn($table = Mockery::mock('stdClass'));
79-
$table->shouldReceive('whereIn')
80-
->with('id', [1])
81-
->andReturnSelf();
8289
$table->shouldReceive('update')
90+
->once()
8391
->with(['searchable' => null]);
8492

85-
$engine->delete(Collection::make([new TestModel()]));
93+
$engine->flush(new TestModel());
94+
}
95+
96+
public function test_flush_does_nothing_if_index_maintenance_turned_off_globally()
97+
{
98+
list($engine, $db) = $this->getEngine(['maintain_index' => false]);
99+
100+
$db->shouldNotReceive('table');
101+
102+
$engine->flush(new TestModel());
86103
}
87104

88105
public function test_search()

0 commit comments

Comments
 (0)