File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/app/Library/CrudPanel Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 2525 * @method self visibleInExport(bool $value)
2626 * @method self visibleInShow(bool $value)
2727 * @method self priority(int $value)
28+ * @method self key(string $value)
2829 */
2930class CrudColumn
3031{
@@ -66,6 +67,25 @@ public static function name($name)
6667 return new static ($ name );
6768 }
6869
70+ /**
71+ * Change the CrudColumn key.
72+ *
73+ * @param string $key New key for the column
74+ * @return CrudColumn
75+ */
76+ public function key (string $ key )
77+ {
78+ if (! isset ($ this ->attributes ['name ' ])) {
79+ abort (500 , 'Column name must be defined before changing the key. ' );
80+ }
81+ if ($ this ->crud ()->hasColumnWhere ('key ' , $ this ->attributes ['key ' ])) {
82+ $ this ->crud ()->setColumnDetails ($ this ->attributes ['key ' ], array_merge ($ this ->attributes , ['key ' => $ key ]));
83+ }
84+ $ this ->attributes ['key ' ] = $ key ;
85+
86+ return $ this ;
87+ }
88+
6989 /**
7090 * Remove the current column from the current operation.
7191 *
You can’t perform that action at this time.
0 commit comments