protected function ensureExists($model) { if ($this->related !== $model) { $this->related = $model; parent::ensureExists($model); } }
protected function ensureExists($model) { $this->ensureCollection(); if (!$this->has($model)) { $this->related->add($model); parent::ensureExists($model); } }