改进中间表名读取

This commit is contained in:
thinkphp
2017-03-17 19:03:01 +08:00
parent f4629107a2
commit 224a9d5bb3

View File

@@ -44,10 +44,11 @@ class BelongsToMany extends Relation
$this->model = $model;
$this->foreignKey = $foreignKey;
$this->localKey = $localKey;
if (false === strpos($table, '\\')) {
$this->middle = $table;
} else {
if (false !== strpos($table, '\\')) {
$this->pivotName = $table;
$this->middle = basename(str_replace('\\', '/', $table));
} else {
$this->middle = $table;
}
$this->query = (new $model)->db();
$this->pivot = $this->newPivot();