Spot\Mapper::saveHasRelations PHP 메소드

saveHasRelations() 공개 메소드

Save related entities that have been assigned or loaded (only HasOne, HasMany and HasManyThrough relations) See saveBelongsToRelations.
public saveHasRelations ( EntityInterface $entity, array $options = [] ) : mixed
$entity EntityInterface
$options array
리턴 mixed
    public function saveHasRelations(EntityInterface $entity, array $options = [])
    {
        if ($entity->isNew()) {
            throw new \InvalidArgumentException("The provided entity is new. The entity must be persisted before saving relations.");
        }
        $relations = $entity->relations($this, $entity);
        $lastResult = false;
        foreach ($relations as $relationName => $relation) {
            if (!$relation instanceof Relation\BelongsTo) {
                $lastResult = $relation->save($entity, $relationName, $options);
            }
        }
        return $lastResult;
    }