diff --git a/src/Html/Options/HasColumns.php b/src/Html/Options/HasColumns.php index a1d239d..7739a89 100644 --- a/src/Html/Options/HasColumns.php +++ b/src/Html/Options/HasColumns.php @@ -27,6 +27,15 @@ public function columnDefs(array $value) return $this; } + private function camelRelation($column) + { + + $parts = explode('.', $column); + $columnName = array_pop($parts); + $relation = Str::camel(implode('.', $parts)); + + return $relation . ($relation ? '.' : '') . $columnName; + } /** * Set columns option value. * @@ -43,14 +52,14 @@ public function columns(array $columns) if (is_array($value)) { $attributes = array_merge( [ - 'name' => $value['name'] ?? $value['data'] ?? $key, + 'name' => $value['name'] ?? $this->camelRelation($value['data'] ?? $key), 'data' => $value['data'] ?? $key, ], $this->setTitle($key, $value) ); } else { $attributes = [ - 'name' => $value, + 'name' => $this->camelRelation($value), 'data' => $value, 'title' => $this->getQualifiedTitle($value), ];