Relation类save方法支持传入模型对象

This commit is contained in:
thinkphp
2016-05-06 16:23:13 +08:00
parent e71a864915
commit b8e5437f1c

View File

@@ -453,6 +453,9 @@ class Relation
*/
public function save($data, array $pivot = [])
{
if ($data instanceof Model) {
$data = $data->toArray();
}
// 判断关联类型
switch ($this->type) {
case self::HAS_ONE: