修复主键为字符串时返回0的问题

This commit is contained in:
walkor 2023-05-16 11:16:46 +08:00
parent 5d3ce0ff12
commit ca2af73a2c
2 changed files with 15 additions and 3 deletions

View File

@ -563,6 +563,7 @@ class TableController extends Base
$pk = 'id';
$properties = '';
$timestamps = '';
$incrementing = '';
$columns = [];
try {
$database = config('database.connections')['plugin.admin.mysql']['database'];
@ -571,6 +572,18 @@ class TableController extends Base
if ($item->COLUMN_KEY === 'PRI') {
$pk = $item->COLUMN_NAME;
$item->COLUMN_COMMENT .= "(主键)";
if (strpos(strtolower($item->DATA_TYPE), 'int') === false) {
$incrementing = <<<EOF
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public \$incrementing = false;
EOF;
;
}
}
$type = $this->getType($item->DATA_TYPE);
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
@ -585,6 +598,7 @@ class TableController extends Base
* @var bool
*/
public \$timestamps = false;
EOF;
}
@ -614,9 +628,8 @@ class $class extends Base
* @var string
*/
protected \$primaryKey = '$pk';
$timestamps
$incrementing
}

View File

@ -125,7 +125,6 @@
return layui.popup.failure(res.msg);
}
return layui.popup.success("操作成功", function () {
parent.refreshTable();
parent.layer.close(parent.layer.getFrameIndex(window.name));
});
}