Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 5d958ee

Browse files
committed
Fixed type hint for the searchRaw method. Now it accepts any eloquent model.
1 parent 29b6cf7 commit 5d958ee

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"autoload": {
2828
"psr-4": {
29+
"ScoutElastic\\Tests\\": "tests/",
2930
"ScoutElastic\\": "src/"
3031
}
3132
}

src/ElasticEngine.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use ScoutElastic\Builders\SearchBuilder;
1010
use ScoutElastic\Facades\ElasticClient;
1111
use Illuminate\Database\Eloquent\Collection;
12+
use Illuminate\Database\Eloquent\Model;
1213

1314
class ElasticEngine extends Engine
1415
{
@@ -285,7 +286,7 @@ public function paginate(Builder $builder, $perPage, $page)
285286
]);
286287
}
287288

288-
public function searchRaw(SearchableModel $model, $query)
289+
public function searchRaw(Model $model, $query)
289290
{
290291
$payload = $this->buildTypePayload($model, $query);
291292
return ElasticClient::search($payload);

tests/ElasticEngineTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use ScoutElastic\Builders\SearchBuilder;
1111
use ScoutElastic\ElasticEngine;
1212
use ScoutElastic\IndexConfigurator;
13-
use ScoutElastic\SearchableModel;
1413
use ScoutElastic\Facades\ElasticClient;
1514

1615
class ElasticEngineTest extends PHPUnit_Framework_TestCase
@@ -44,7 +43,7 @@ protected function initModel($fields = [])
4443
->andReturn('test_index')
4544
->getMock();
4645

47-
return Mockery::mock(SearchableModel::class)
46+
return Mockery::mock(ModelStub::class)
4847
->makePartial()
4948
->forceFill($fields)
5049
->shouldReceive('getIndexConfigurator')

tests/ModelStub.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace ScoutElastic\Tests;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use ScoutElastic\Searchable;
7+
8+
class ModelStub extends Model
9+
{
10+
use Searchable;
11+
}

0 commit comments

Comments
 (0)