/**
  * @see https://www.pivotaltracker.com/story/show/58372836
  * This method is called to resolve the issue of the cache having incorrect information and requiring a clearCache
  * Now after saving, it will resolve the related model correctly.
  * @param RedBeanModel $precedingModel
  * @param string $precedingRelation
  * @param RedBeanModel $model
  */
 protected function resolveOneToManyPostCreateActionSaveModelCache(RedBeanModel $precedingModel, $precedingRelation, RedBeanModel $model)
 {
     if ($precedingModel->{$precedingRelation} instanceof RedBeanOneToManyRelatedModels) {
         $relationToUse = null;
         foreach ($model->getAttributes() as $attributeName => $notUsed) {
             if ($model->isRelation($attributeName)) {
                 if (RedBeanModel::relationLinksToPrecedingRelation(get_class($model), $attributeName, get_class($precedingModel), $precedingRelation)) {
                     $relationToUse = $attributeName;
                     break;
                 }
             }
         }
         if ($relationToUse != null) {
             $model->{$relationToUse} = $precedingModel;
         }
     }
 }
 /**
  * @param string $relation
  * @param null|RedBeanModel $precedingModel
  * @param null|string $precedingRelation
  * @return bool
  */
 protected function relationLinksToPrecedingRelation($relation, RedBeanModel $precedingModel = null, $precedingRelation = null)
 {
     return RedBeanModel::relationLinksToPrecedingRelation(get_class($this->model), $relation, get_class($precedingModel), $precedingRelation);
 }