Browse Source

修复Grid一对一模型字段读取语言包翻译异常问题

jqh 5 years ago
parent
commit
fd1e8fd84e
2 changed files with 2 additions and 10 deletions
  1. 1 5
      src/Grid.php
  2. 1 5
      src/Grid/Column.php

+ 1 - 5
src/Grid.php

@@ -246,14 +246,10 @@ class Grid
         if (mb_strpos($name, '.') !== false) {
             [$relationName, $relationColumn] = explode('.', $name);
 
-            $label = empty($label) ? admin_trans_field($relationColumn) : $label;
-
             $name = Str::snake($relationName).'.'.$relationColumn;
         }
 
-        $column = $this->addColumn($name, $label);
-
-        return $column;
+        return $this->addColumn($name, $label);
     }
 
     /**

+ 1 - 5
src/Grid/Column.php

@@ -413,11 +413,7 @@ class Column
      */
     protected function formatLabel($label)
     {
-        if (! $label) {
-            $label = admin_trans_field($this->name);
-        }
-
-        $label = $label ?: $this->name;
+        $label = $label ?: admin_trans_field($this->name);
 
         return str_replace(['.', '_'], ' ', $label);
     }