This commit is contained in:
Dave Mc Nicoll committed 2021-11-24 16:36:13 +00:00
commit f14347f01d
9 files changed
+245 -131

No files matched your search

+9 -1
View File
@@ -118,7 +118,7 @@ class RelationBuilder
$this->repository->open();
foreach($this->wheres as $condition) {
$this->repository->where($condition->field, $condition->value, $condition->operator);
$this->repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [ $this->entity ]) : $condition->value, $condition->operator);
}
$this->repository->close();
@@ -155,7 +155,10 @@ class RelationBuilder
$entity = $annotation->entity ?? $this->resolver->properties[$name]['type'];
}
$name = strtolower($name);
foreach($data ?: $this->entity->entityLoadedDataset as $key => $value) {
if ( $key === sprintf(static::SUBQUERY_FIELD_SUFFIX, strtolower($name)) ) {
if ($value) {
if ( null === ( $dataset = \json_decode($value, true) ) ) {
@@ -227,6 +230,11 @@ class RelationBuilder
})->where( $this->entity::field($bridgeRelation->foreignKey, $relationAlias), is_string($this->entity) ? $this->entity::field($bridgeRelation->foreignKey) : $this->entity->{$bridgeRelation->foreignKey} );
$this->applyWhere();
$this->applyOrderBy();
if ($selectBridgeField && $relation->bridgeField) {
$this->repository->selectEntity($relation->bridge, $bridgeAlias, $bridgeAlias);
}