Skip to content

Commit 76633db

Browse files
committed
Support Scout 5
For now just complying with the updated interface and not taking advantage of any changes.
1 parent d27243d commit 76633db

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@
1111
],
1212
"homepage": "https://github.com/pmatseykanets/laravel-scout-postgres",
1313
"license": "MIT",
14+
"support": {
15+
"issues": "https://github.com/pmatseykanets/laravel-scout-postgres/issues",
16+
"source": "https://github.com/pmatseykanets/laravel-scout-postgres"
17+
},
1418
"authors": [
1519
{
1620
"name": "Peter Matseykanets",
1721
"email": "pmatseykanets@gmail.com",
1822
"homepage": "https://github.com/pmatseykanets",
19-
"role": "Developer"
2023
}
2124
],
2225
"require": {
2326
"php": ">=7.0",
24-
"illuminate/contracts": "~5.4",
25-
"illuminate/database": "~5.4",
26-
"illuminate/support": "~5.4",
27-
"laravel/scout": "~4.0"
27+
"illuminate/contracts": "~5.4|~5.5|~5.6",
28+
"illuminate/database": "~5.4|~5.5|~5.6",
29+
"illuminate/support": "~5.4|~5.5|~5.6",
30+
"laravel/scout": "~5.0"
2831
},
2932
"require-dev": {
3033
"phpunit/phpunit": "~6.0",

src/PostgresEngine.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ public function mapIds($results)
312312
/**
313313
* Map the given results to instances of the given model.
314314
*
315-
* @param mixed $results
316-
* @param \Illuminate\Database\Eloquent\Model $model
317-
* @return \Illuminate\Support\Collection
315+
* @param \Laravel\Scout\Builder $builder
316+
* @param mixed $results
317+
* @param \Illuminate\Database\Eloquent\Model $model
318+
* @return \Illuminate\Database\Eloquent\Collection
318319
*/
319-
public function map($results, $model)
320+
public function map(Builder $builder, $results, $model)
320321
{
321322
if (empty($results)) {
322323
return Collection::make();

tests/PostgresEngineTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ public function test_maps_results_to_models()
205205
$model->shouldReceive('get')->once()->andReturn(Collection::make([new TestModel()]));
206206

207207
$results = $engine->map(
208-
json_decode('[{"id": 1, "tsrank": 0.33, "total_count": 1}]'), $model);
208+
new Builder(new TestModel, 'foo'),
209+
json_decode('[{"id": 1, "tsrank": 0.33, "total_count": 1}]'),
210+
$model
211+
);
209212

210213
$this->assertCount(1, $results);
211214
}
@@ -224,7 +227,10 @@ public function test_map_filters_out_no_longer_existing_models()
224227
$model->shouldReceive('get')->once()->andReturn(Collection::make([$expectedModel]));
225228

226229
$models = $engine->map(
227-
json_decode('[{"id": 1, "tsrank": 0.33, "total_count": 2}, {"id": 2, "tsrank": 0.31, "total_count": 2}]'), $model);
230+
new Builder(new TestModel, 'foo'),
231+
json_decode('[{"id": 1, "tsrank": 0.33, "total_count": 2}, {"id": 2, "tsrank": 0.31, "total_count": 2}]'),
232+
$model
233+
);
228234

229235
$this->assertCount(1, $models);
230236
$this->assertEquals(2, $models->first()->id);

0 commit comments

Comments
 (0)