修正多对多默认的中间表获取

This commit is contained in:
thinkphp
2017-06-23 14:05:28 +08:00
parent e427ae5776
commit 915c46c4bd

View File

@@ -1939,7 +1939,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 记录当前关联信息
$model = $this->parseModel($model);
$name = Loader::parseName(basename(str_replace('\\', '/', $model)));
$table = $table ?: $this->getQuery()->getTable(Loader::parseName($this->name) . '_' . $name);
$table = $table ?: Loader::parseName($this->name) . '_' . $name;
$foreignKey = $foreignKey ?: $name . '_id';
$localKey = $localKey ?: $this->getForeignKey($this->name);
return new BelongsToMany($this, $model, $table, $foreignKey, $localKey);