{"action":"opened","issue":{"url":"https://api.github.com/repos/top-think/framework/issues/529","repository_url":"https://api.github.com/repos/top-think/framework","labels_url":"https://api.github.com/repos/top-think/framework/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/top-think/framework/issues/529/comments","events_url":"https://api.github.com/repos/top-think/framework/issues/529/events","html_url":"https://github.com/top-think/framework/issues/529","id":211761766,"number":529,"title":"HasMany->save(Model) 与 Model->SetXxxAttr 冲突","user":{"login":"ganlvtech","id":8651285,"avatar_url":"https://avatars3.githubusercontent.com/u/8651285?v=3","gravatar_id":"","url":"https://api.github.com/users/ganlvtech","html_url":"https://github.com/ganlvtech","followers_url":"https://api.github.com/users/ganlvtech/followers","following_url":"https://api.github.com/users/ganlvtech/following{/other_user}","gists_url":"https://api.github.com/users/ganlvtech/gists{/gist_id}","starred_url":"https://api.github.com/users/ganlvtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ganlvtech/subscriptions","organizations_url":"https://api.github.com/users/ganlvtech/orgs","repos_url":"https://api.github.com/users/ganlvtech/repos","events_url":"https://api.github.com/users/ganlvtech/events{/privacy}","received_events_url":"https://api.github.com/users/ganlvtech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-03T18:10:45Z","updated_at":"2017-03-03T18:10:45Z","closed_at":null,"body":"```php\r\n$group->users()->save($user);\r\n```\r\n\r\n当使用以上语句新增用户时，如果用户的某字段有修改器，则会再叠加一层修改\r\n\r\nin `thinkphp/library/think/model/relation/HasMany.php:188`\r\n\r\n```php\r\n    public function save($data) // $data传入Model类型\r\n    {\r\n        if ($data instanceof Model) {\r\n            $data = $data->getData(); // 此处获取了原始数据\r\n        }\r\n        // 保存关联表数据\r\n        $data[$this->foreignKey] = $this->parent->{$this->localKey};\r\n        $model                   = new $this->model;\r\n        return $model->save($data); // 此处保存数据时使用了修改器\r\n    }\r\n```"}}
{"actor":{"display_login":"ganlvtech"}}