Commit a4239efa by Qiang Xue

Fixes #637.

parent b28e6b90
......@@ -1256,6 +1256,9 @@ class ActiveRecord extends Model
$relation = $this->getRelation($name);
if ($relation->via !== null) {
if ($this->getIsNewRecord() || $model->getIsNewRecord()) {
throw new InvalidCallException('Unable to link models: both models must NOT be newly created.');
}
if (is_array($relation->via)) {
/** @var $viaRelation ActiveRelation */
list($viaName, $viaRelation) = $relation->via;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment