Elasticquent
Elasticquent copied to clipboard
When i call $model->addToIndex();
BadMethodCallException Method Illuminate\Database\Eloquent\Collection::addToIndex does not exist.
Seems like you're calling addToIndex()
on a Collection (of models, presumably) not on a single Model.
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();
Extend ElasticquentCollection or add "use ElasticquentCollectionTrait;" to your Eloquent models
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.
@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()".