Skip to content

Commit 6d12f77

Browse files
authored
Merge pull request #5454 from mis3085/fix_grid_model_setsort_is_relation
修正Grid無法對關聯欄位使用sortable()的問題
2 parents 8189b3e + 8ce1017 commit 6d12f77

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Grid/Model.php

+5
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ protected function setSort()
526526

527527
$columnNameContainsDots = Str::contains($columnName, '.');
528528
$isRelation = $this->queries->contains(function ($query) use ($columnName) {
529+
// relationship should be camel case
530+
$columnName = Str::camel(Str::before($columnName, '.'));
531+
529532
return $query['method'] === 'with' && in_array($columnName, $query['arguments'], true);
530533
});
531534
if ($columnNameContainsDots === true && $isRelation) {
@@ -570,6 +573,8 @@ protected function setSort()
570573
protected function setRelationSort($column)
571574
{
572575
list($relationName, $relationColumn) = explode('.', $column);
576+
// relationship should be camel case
577+
$relationName = Str::camel($relationName);
573578

574579
if ($this->queries->contains(function ($query) use ($relationName) {
575580
return $query['method'] == 'with' && in_array($relationName, $query['arguments']);

0 commit comments

Comments
 (0)