From d1a887cad7566761ee4890dd127e1c25f206cbcd Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 11 Dec 2018 11:14:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=85=B3=E8=81=94=E7=9A=84sa?= =?UTF-8?q?ve=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/HasMany.php | 4 +++- library/think/model/relation/MorphMany.php | 3 ++- library/think/model/relation/MorphOne.php | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/think/model/relation/HasMany.php b/library/think/model/relation/HasMany.php index c4b31af9..4f2b9abb 100644 --- a/library/think/model/relation/HasMany.php +++ b/library/think/model/relation/HasMany.php @@ -202,7 +202,9 @@ class HasMany extends Relation */ public function save($data) { - $model = $this->make($data); + $model = $this->make(); + $data = array_merge($model->getData(), $data); + return $model->save($data) ? $model : false; } diff --git a/library/think/model/relation/MorphMany.php b/library/think/model/relation/MorphMany.php index 941ebe8b..e783136a 100644 --- a/library/think/model/relation/MorphMany.php +++ b/library/think/model/relation/MorphMany.php @@ -245,7 +245,8 @@ class MorphMany extends Relation */ public function save($data) { - $model = $this->make($data); + $model = $this->make(); + $data = array_merge($model->getData(), $data); return $model->save($data) ? $model : false; } diff --git a/library/think/model/relation/MorphOne.php b/library/think/model/relation/MorphOne.php index 1f4bffd7..a32fd5dc 100644 --- a/library/think/model/relation/MorphOne.php +++ b/library/think/model/relation/MorphOne.php @@ -199,8 +199,10 @@ class MorphOne extends Relation */ public function save($data) { - $model = $this->make($data); - return $model->save() ? $model : false; + $model = $this->make(); + $data = array_merge($model->getData(), $data); + + return $model->save($data) ? $model : false; } /**