Merge branch 'master' of https://git.mcnd.ca/mcndave/ulmus
This commit is contained in:
		
						commit
						fa8adcace1
					
				| @ -12,12 +12,14 @@ class Where { | ||||
|         public mixed $value = null, | ||||
|         public string $operator = Query\Where::OPERATOR_EQUAL, | ||||
|         public string $condition = Query\Where::CONDITION_AND, | ||||
|         public null|\Stringable|array $foreignField = null, | ||||
|         public string|\Stringable|array|null $fieldValue = null, | ||||
|     ) { | ||||
|         $this->field = Attribute::handleArrayField($field); | ||||
|         $this->fieldValue = Attribute::handleArrayField($fieldValue); | ||||
|     } | ||||
| 
 | ||||
|         if ($foreignField) { | ||||
|             $this->value = Attribute::handleArrayField($foreignField); | ||||
|         } | ||||
|     public function getValue() : mixed | ||||
|     { | ||||
|         return $this->fieldValue ?? $this->value; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -620,18 +620,16 @@ class Repository | ||||
| 
 | ||||
|                 foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Where::class, Where::class ] ) as $condition) { | ||||
|                     if ( is_object($condition->field) && ( $condition->field->entityClass !== $entity ) ) { | ||||
|                         $this->where(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->value, $condition->operator); | ||||
|                         $this->where(is_object($condition->field) ? $condition->field : $entity::field($condition->field),  $condition->getValue(), $condition->operator); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Having::class, Having::class ] ) as $condition) { | ||||
|                     $this->having(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->value, $condition->operator); | ||||
|                     $this->having(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->getValue(), $condition->operator); | ||||
|                 } | ||||
| 
 | ||||
|                 if ( empty($this->entityResolver->searchFieldAnnotationList($item,  [ Attribute\Property\FilterJoin::class, FilterJoin::class ])) ) { | ||||
|                     foreach ($this->entityResolver->searchFieldAnnotationList($item, [Attribute\Property\Filter::class, Filter::class]) as $filter) { | ||||
|                         call_user_func_array([$this->entityClass, $filter->method], [$this, $item, true]); | ||||
|                     } | ||||
|                 foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Filter::class, Filter::class ] ) as $filter) { | ||||
|                     call_user_func_array([ $this->entityClass, $filter->method ], [ $this, $item, true ]); | ||||
|                 } | ||||
| 
 | ||||
|                 $this->close(); | ||||
| @ -653,7 +651,7 @@ class Repository | ||||
|                         if ( $field->entityClass === $entity ) { | ||||
|                             $field->alias = $alias; | ||||
| 
 | ||||
|                             $join->where(is_object($field) ? $field : $entity::field($field, $alias), $condition->value, $condition->operator); | ||||
|                             $join->where(is_object($field) ? $field : $entity::field($field, $alias), $condition->getValue(), $condition->operator); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
| @ -702,14 +700,14 @@ class Repository | ||||
|                     $repository = $entity::repository()->selectJsonEntity($entity, $alias)->open(); | ||||
|                 } | ||||
| 
 | ||||
|                 # @TODO ? $relation->isManyToMany() and $repository->selectJsonEntity($relation->bridge, $relation->bridgeField, true);
 | ||||
|                 #  $relation->isManyToMany() and $repository->selectJsonEntity($relation->bridge, $relation->bridgeField, true);
 | ||||
| 
 | ||||
|                 foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Where::class, Where::class ]) as $condition) { | ||||
|                     $repository->where(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->value, $condition->operator); | ||||
|                     $repository->where(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->getValue(), $condition->operator); | ||||
|                 } | ||||
| 
 | ||||
|                 foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Having::class, Having::class ] ) as $condition) { | ||||
|                     $repository->having(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->value, $condition->operator); | ||||
|                     $repository->having(is_object($condition->field) ? $condition->field : $entity::field($condition->field), $condition->getValue(), $condition->operator); | ||||
|                 } | ||||
| 
 | ||||
|                 $repository->close(); | ||||
| @ -754,7 +752,7 @@ class Repository | ||||
|                 } | ||||
| 
 | ||||
|                 foreach ($where as $condition) { | ||||
|                     $repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [$this]) : $condition->value, $condition->operator, $condition->condition); | ||||
|                     $repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [$this]) : $condition->getValue(), $condition->operator, $condition->condition); | ||||
|                 } | ||||
| 
 | ||||
|                 foreach ($order as $item) { | ||||
|  | ||||
| @ -152,7 +152,7 @@ class RelationBuilder | ||||
|             $this->repository->open(); | ||||
| 
 | ||||
|             foreach($this->wheres as $condition) { | ||||
|                 $this->repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [ $this->entity ]) : $condition->value, $condition->operator); | ||||
|                 $this->repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [ $this->entity ]) : $condition->getValue(), $condition->operator); | ||||
|             } | ||||
| 
 | ||||
|             $this->repository->close(); | ||||
| @ -262,9 +262,6 @@ class RelationBuilder | ||||
|         $field = $relation->key; | ||||
| 
 | ||||
|         if ($relation->foreignKey) { | ||||
|            # dump($baseEntity::resolveEntity()->searchField($field));
 | ||||
| 
 | ||||
| #            dump($this->resolver->properties[$name], $field);
 | ||||
|             $value = ! is_string($field) && is_callable($field) ? $field($this->entity) : $this->entity->$field; | ||||
|             $this->repository->where( is_object($relation->foreignKey) ? $relation->foreignKey : $baseEntity::field($relation->foreignKey), $value ); | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user