Skip to content

Commit

Permalink
[5.x] Fixed ordering search results by origin value (#11334)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Jan 22, 2025
1 parent b07b70b commit 6a3bcde
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Data/DataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ protected function getSortableValue($sort, $item)
return $this->normalizeSortableValue($item[$sort] ?? null);
}

$method = Str::camel($sort);

if ($item instanceof Result && ! $item instanceof PlainResult) {
$item = $item->getSearchable() ?? $item;
}

$value = (method_exists($item, $method))
? call_user_func([$item, $method])
: $item->get($sort);
if (method_exists($item, $method = Str::camel($sort))) {
return $this->normalizeSortableValue(call_user_func([$item, $method]));
}

if (method_exists($item, 'value')) {
return $this->normalizeSortableValue($item->value($sort));
}

return $this->normalizeSortableValue($value);
return $this->normalizeSortableValue($item->get($sort));
}

/**
Expand Down

0 comments on commit 6a3bcde

Please sign in to comment.