This commit is contained in:
thinkphp
2018-10-26 16:22:16 +08:00
parent aea62e8d07
commit b90b6a1ecb

View File

@@ -522,14 +522,13 @@ class BelongsToMany extends Relation
/**
* 判断是否存在关联数据
* @access public
* @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键
* @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键
* @return Pivot
* @throws Exception
*/
public function attached($data)
{
if ($data instanceof Model) {
// 根据关联表主键直接写入中间表
$relationFk = $data->getPk();
$id = $data->$relationFk;
} else {