This commit is contained in:
thinkphp
2016-12-23 10:53:39 +08:00

View File

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