mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
优化getChangedData判断
修复多态关联无法保存的问题
This commit is contained in:
@@ -1267,10 +1267,18 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
} else {
|
} else {
|
||||||
$data = array_udiff_assoc($this->data, $this->origin, function ($a, $b) {
|
$data = array_udiff_assoc($this->data, $this->origin, function ($a, $b) {
|
||||||
|
if (is_numeric($a) && is_numeric($b)) {
|
||||||
|
if (strcmp($a, $b) !== 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ($a == $b) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((empty($a) || empty($b)) && $a !== $b) {
|
if ((empty($a) || empty($b)) && $a !== $b) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return is_object($a) || $a != $b ? 1 : 0;
|
return is_object($a) || $a !== $b ? 1 : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class MorphOne extends Relation
|
|||||||
|
|
||||||
$model = new $this->model();
|
$model = new $this->model();
|
||||||
|
|
||||||
return $model->save() ? $model : false;
|
return $model->save($data) ? $model : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user