laravel-scout-tntsearch-driver: Declaration of TeamTNT\Scout\Engines\TNTSearchEngine::map($results, $model) must be compatible with Laravel\Scout\Engines\Engine::map(Laravel\Scout\Builder $builder, $results, $model)

Declaration of TeamTNT\Scout\Engines\TNTSearchEngine::map($results, $model) must be compatible with Laravel\Scout\Engines\Engine::map(Laravel\Scout\Builder $builder, $results, $model)

I am receiving this exception when calling search() on a model.

I have temporarily fixed this by changing the signature of the map function from public function map($results, $model) to public function map(Builder $builder, $results, $model)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

just created another release v3.1.0 that will force laravel scout 5.0.*, so the error should be gone

Update: Downgrading to Scout v4.* works.

On composer json:

        "laravel/scout": "^4.0",

Then:

composer update

@Krato already fixed it in the master, but there is no release yet. You can require it with

        "teamtnt/laravel-scout-tntsearch-driver": "dev-master"

i ran composer update and it installed v3.0.8 but i still get the error. maybe there’s something else i’m supposed to do?

@nticaric v3.1.0 will cause another problem

Call to undefined method Illuminate\Database\Query\Builder::leftJoinSub()

I’ve updated to v3.0.8 but I’m still receiving this error when saving or creating a searchable model 😭

Declaration of TeamTNT\Scout\Engines\TNTSearchEngine::map(Laravel\Scout\Builder $builder, $results,
$model) must be compatible with Laravel\Scout\Engines\Engine::map($results, $model)

Same for me. (New user here!) Will be this fixed soon? I have a deadline and I need to know if can I use this package. Thanks. 😄

Laravel: v5.6.28
Scout: v5.0.2
TNTSearch driver: v3.0.7

Edit: I have found the breaking change in Laravel Scout: https://github.com/laravel/scout/commit/9f06b9c4d77879d53cf1680740b7f8bf19f78279#diff-c0a1ec7dbf011155e6c41c1f05d39fffR60

Okay when creating a model I have used search() in I’m receiving:

ErrorException (E_NOTICE)  
Undefined index: id  
\vendor\teamtnt\tntsearch\src\Support\Collection.php:97

Also worth noting that php artisan scout:import \App\ModelName didn’t work but during setup but php artisan tntsearch:import \App\ModelName did.