This commit is contained in:
thinkphp
2016-12-22 23:57:47 +08:00
parent 6433f8fdca
commit 4b6a39f6d3

View File

@@ -239,9 +239,11 @@ class BelongsToMany extends Relation
$result = false;
foreach ($dataSet as $key => $data) {
if (!$samePivot) {
$pivot = isset($pivot[$key]) ? $pivot[$key] : [];
$pivotData = isset($pivot[$key]) ? $pivot[$key] : [];
} else {
$pivotData = $pivot;
}
$result = $this->attach($data, $pivot);
$result = $this->attach($data, $pivotData);
}
return $result;
}