diff --git a/src/Grid/Model.php b/src/Grid/Model.php index 5949056f20..32036fb582 100644 --- a/src/Grid/Model.php +++ b/src/Grid/Model.php @@ -526,6 +526,9 @@ protected function setSort() $columnNameContainsDots = Str::contains($columnName, '.'); $isRelation = $this->queries->contains(function ($query) use ($columnName) { + // relationship should be camel case + $columnName = Str::camel(Str::before($columnName, '.')); + return $query['method'] === 'with' && in_array($columnName, $query['arguments'], true); }); if ($columnNameContainsDots === true && $isRelation) { @@ -570,6 +573,8 @@ protected function setSort() protected function setRelationSort($column) { list($relationName, $relationColumn) = explode('.', $column); + // relationship should be camel case + $relationName = Str::camel($relationName); if ($this->queries->contains(function ($query) use ($relationName) { return $query['method'] == 'with' && in_array($relationName, $query['arguments']);