refactor:优化去除关联字段后缀的逻辑

This commit is contained in:
妙码生花 2023-07-19 04:48:59 +08:00
parent 932346febe
commit 42200f179f

View File

@ -564,7 +564,7 @@ class Crud extends Backend
$columns = Helper::parseTableColumns($field['form']['remote-table'], true);
$relationFields = explode(',', $field['form']['relation-fields']);
$tableName = TableManager::tableName($field['form']['remote-table'], false);
$relationName = parse_name(rtrim(rtrim($field['name'], '_ids'), '_id'), 1, false);
$relationName = parse_name(preg_replace('/(.*)(_ids|_id)$/', '$1', $field['name']), 1, false);
// 建立关联模型代码文件
if (!$field['form']['remote-model'] || !file_exists(root_path() . $field['form']['remote-model'])) {