diff --git a/library/think/Model.php b/library/think/Model.php index 6f74d388..726110b5 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1998,7 +1998,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $trace = debug_backtrace(false, 2); $morph = Loader::parseName($trace[1]['function']); } - $type = $type ?: Loader::parseName($this->name); + $type = $type ?: get_class($this); if (is_array($morph)) { list($morphType, $foreignKey) = $morph; } else { @@ -2024,7 +2024,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $trace = debug_backtrace(false, 2); $morph = Loader::parseName($trace[1]['function']); } - $type = $type ?: Loader::parseName($this->name); + $type = $type ?: get_class($this); if (is_array($morph)) { list($morphType, $foreignKey) = $morph; } else { diff --git a/library/think/model/relation/MorphTo.php b/library/think/model/relation/MorphTo.php index c8ef1a49..9136d78e 100644 --- a/library/think/model/relation/MorphTo.php +++ b/library/think/model/relation/MorphTo.php @@ -248,7 +248,7 @@ class MorphTo extends Relation $pk = $model->getPk(); $this->parent->setAttr($morphKey, $model->$pk); - $this->parent->setAttr($morphType, basename(get_class($model))); + $this->parent->setAttr($morphType, get_class($model)); $this->parent->save(); return $this->parent->setRelation($this->relation, $model);