/**
  * Unrelates a model by index. Override to support finding opposing relation and making adjustment
  * so when accessing the opposing model, it will reflect properly the changes to the relation.
  * Ignoring when the relations are for the same model, because there is currently an issue with this being supported
  * with group/groups. Eventually todo: fix that and we can open it up to relations with the same model.
  */
 public function removeByIndex($i)
 {
     $model = $this->getByIndex($i);
     parent::removeByIndex($i);
     if (get_class($model) != get_class($this->relatedModel) && null != ($opposingRelationName = $this->getOpposingRelationName($model))) {
         $model->{$opposingRelationName} = null;
         $this->deferredUnrelatedModels[] = $model;
     }
 }