diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index 4c768ba6..cd4bdfe6 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -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();