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

When i call $model->addToIndex(); #176

Open
sfdsfdsfdesfdsghefasefs opened this issue Oct 30, 2018 · 5 comments
Open

When i call $model->addToIndex(); #176

sfdsfdsfdesfdsghefasefs opened this issue Oct 30, 2018 · 5 comments

Comments

@sfdsfdsfdesfdsghefasefs

BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::addToIndex does not exist.

@d1am0nd
Copy link

d1am0nd commented Nov 5, 2018

Seems like you're calling addToIndex() on a Collection (of models, presumably) not on a single Model.

@maganius
Copy link

maganius commented Dec 6, 2018

Seems like you're calling addToIndex() on a Collection (of models, presumably) not on a single Model.

I have same error, in the docs say its possible...

You can also index a collection of models:

    $books = Book::where('id', '<', 200)->get();
    $books->addToIndex();

@coffeeburrito
Copy link
Contributor

Extend ElasticquentCollection or add "use ElasticquentCollectionTrait;" to your Eloquent models

@Olegars
Copy link

Olegars commented Jan 14, 2019

Hi
I have the same problem

use Illuminate\Database\Eloquent\Model;
use Elasticquent\ElasticquentTrait;

class wear extends Model
{
use ElasticquentTrait;

BadMethodCallException : Method Elasticquent\ElasticquentCollection::addAllToIndex does not exist.

@coffeeburrito
Copy link
Contributor

@Olegars, your code doesn't match the error. Your sample shows "ElasticquentTrait", but the error shows "ElasticquentCollection".

Regardless, note that ElasticquentCollectionTrait has "addToIndex()", while ElasticquentTrait has "addAllToIndex()".

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

5 participants