diff --git a/src/BatchSearchable.php b/src/BatchSearchable.php index b415648..578e29d 100644 --- a/src/BatchSearchable.php +++ b/src/BatchSearchable.php @@ -78,7 +78,7 @@ private function addToBatchingQueue($models, $makeSearchable = true) { if ($models->isEmpty()) return; $className = get_class($models->first()); - $modelIds = $models->pluck($models->first()->getScoutKeyName())->toArray(); + $modelIds = $models->pluck($models->first()->getKeyName())->toArray(); ServiceProvider::addBatchedModelClass($className); // Add IDs to the requested queue @@ -87,7 +87,7 @@ private function addToBatchingQueue($models, $makeSearchable = true) $existingCacheValue['models'] = is_array($existingCacheValue['models']) ? $existingCacheValue['models'] : []; $newModelIds = array_unique(array_merge($existingCacheValue['models'], $modelIds)); - $newCacheValue = ['updated_at' => Carbon::now(), 'models' => $newModelIds]; + $newCacheValue = ['updated_at' => Carbon::now(), 'models' => array_values($newModelIds)]; // Remove IDs from the opposite queue $opCacheKey = $this->getCacheKey($className, !$makeSearchable); @@ -139,7 +139,7 @@ private function checkBatchingStatusAndDispatchIfNecessaryFor($className, $makeS Cache::forget($cacheKey); $fakeModel = new $className; - $keyName = $fakeModel->getScoutKeyName(); + $keyName = $fakeModel->getKeyName(); $models = collect(); @@ -150,7 +150,7 @@ private function checkBatchingStatusAndDispatchIfNecessaryFor($className, $makeS } else { $models = collect($cachedValue['models'])->map(function ($id) use ($className) { $model = new $className; - $model->{$model->getScoutKeyName()} = $id; + $model->{$model->getKeyName()} = $id; return $model; }); }