Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bradley-varol opened this issue Aug 2, 2018 · 18 comments

Comments

@bradley-varol
Copy link

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)

@bradley-varol
Copy link
Author

bradley-varol commented Aug 2, 2018

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.

@jhm-ciberman
Copy link

jhm-ciberman commented Aug 2, 2018

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: laravel/scout@9f06b9c#diff-c0a1ec7dbf011155e6c41c1f05d39fffR60

jhm-ciberman referenced this issue in laravel/scout Aug 2, 2018
@jhm-ciberman
Copy link

Update: Downgrading to Scout v4.* works.

On composer json:

        "laravel/scout": "^4.0",

Then:

composer update

@bradley-varol
Copy link
Author

Downgrading hasn't fixed this issue for me. When trying to create a new Model, I get

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Declaration of TeamTNT\Scout\Engines\TNTSearchEngine::map(Laravel\Scout\Builder $builder, $results, $model) must be compatible with Laravel\Scout\Engines\Engine::map($results, $model)

@bradley-varol
Copy link
Author

I really need a fix for this otherwise I'm going to have to switch to a different driver.

@jhm-ciberman
Copy link

Sorry, but are you sure you are using Scout 4.0.*?
Can you check the version in composer-lock.json? (Not in composer.json)

Maybe you run composer install instead of composer update

@bradley-varol
Copy link
Author

bradley-varol commented Aug 3, 2018

"name": "laravel/framework",
            "version": "v5.6.29",
            "source": {
                "type": "git",
                "url": "https://github.com/laravel/framework.git",
                "reference": "acc6b5c54ab196d3358f60acc5f55d9ebaaccc02"
            },
"name": "teamtnt/laravel-scout-tntsearch-driver",
            "version": "v3.0.7",
            "source": {
                "type": "git",
                "url": "https://github.com/teamtnt/laravel-scout-tntsearch-driver.git",
                "reference": "048590c769d0d09900d89e32a026d9549558c9a7"
            },
"name": "laravel/scout",
            "version": "v4.0.4",
            "source": {
                "type": "git",
                "url": "https://github.com/laravel/scout.git",
                "reference": "f1b5d65a7d4a70bafaba7ec996176e95341c44ec"
            },

@michaelklopf
Copy link
Contributor

@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"

@nticaric
Copy link
Contributor

nticaric commented Aug 3, 2018

just published a new release with the fix https://github.com/teamtnt/laravel-scout-tntsearch-driver/releases/tag/v3.0.8

@bradley-varol
Copy link
Author

bradley-varol commented Aug 3, 2018

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)

@ITwrx
Copy link

ITwrx commented Aug 3, 2018

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
Copy link
Contributor

nticaric commented Aug 3, 2018

@bradley-varol it's a different error than the one in the title :) it tells us that you don't have the latest scout driver v5.0.2 is the latest

@nticaric
Copy link
Contributor

nticaric commented Aug 3, 2018

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

@bradley-varol
Copy link
Author

Oops, I forgot that I had downgraded my Scout version following jhm-ciberman's suggestion.
Okay, I'm now able to search 🎉 but when updating or creating a model I get

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

php artisan scout:import "App\Model" is also failing with this exception.

@michaelklopf
Copy link
Contributor

@bradley-varol
This kind of error was mentioned here #56

@nticaric nticaric closed this as completed Aug 4, 2018
@hackjie
Copy link

hackjie commented Aug 10, 2018

@nticaric v3.1.0 will cause another problem

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

@michaelklopf
Copy link
Contributor

See #171 for this issue

@D-sense
Copy link

D-sense commented Oct 17, 2018

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

I had a similar issue. This fixed it for me. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants