mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-03 05:41:38 +08:00
改进关联save方法
This commit is contained in:
@@ -202,9 +202,15 @@ class HasMany extends Relation
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$model = $this->make($data);
|
||||
if ($data instanceof Model) {
|
||||
$data = $data->getData();
|
||||
}
|
||||
|
||||
return $model->save() ? $model : false;
|
||||
// 保存关联表数据
|
||||
$data[$this->foreignKey] = $this->parent->{$this->localKey};
|
||||
|
||||
$model = new $this->model();
|
||||
return $model->save($data) ? $model : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user