Skip to content

Commit

Permalink
Misc fixes, revert getScoutKeyName
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Jan 26, 2024
1 parent 9011ef9 commit b264905
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/BatchSearchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -139,7 +139,7 @@ private function checkBatchingStatusAndDispatchIfNecessaryFor($className, $makeS
Cache::forget($cacheKey);

$fakeModel = new $className;
$keyName = $fakeModel->getScoutKeyName();
$keyName = $fakeModel->getKeyName();

$models = collect();

Expand All @@ -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;
});
}
Expand Down

0 comments on commit b264905

Please sign in to comment.