- Added withJoin from attributes in RelationBuilder (can't understand why it wasn't already..)
This commit is contained in:
		
							parent
							
								
									c719e4a6d1
								
							
						
					
					
						commit
						fb644b0b0a
					
				| @ -5,6 +5,6 @@ namespace Ulmus\Attribute\Property; | ||||
| #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
 | ||||
| class WithJoin { | ||||
|     public function __construct( | ||||
|         array $joins = [] | ||||
|         public array $joins = [] | ||||
|     ) {} | ||||
| } | ||||
|  | ||||
| @ -177,6 +177,13 @@ class RelationBuilder | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected function applyWithJoin() : void | ||||
|     { | ||||
|         foreach($this->joins as $item) { | ||||
|             $this->repository->withJoin($item->joins); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected function instanciateEmptyEntity(string $name, Relation $relation) : object | ||||
|     { | ||||
|         $class = $relation->entity ?? $this->resolver->reflectedClass->getProperties()[$name]->getTypes()[0]->type; | ||||
| @ -270,6 +277,8 @@ class RelationBuilder | ||||
| 
 | ||||
|         $this->applyOrderBy(); | ||||
| 
 | ||||
|         $this->applyWithJoin(); | ||||
| 
 | ||||
|         $field = $relation->key; | ||||
| 
 | ||||
|         if ($relation->foreignKey) { | ||||
| @ -313,6 +322,8 @@ class RelationBuilder | ||||
| 
 | ||||
|         $this->applyOrderBy(); | ||||
| 
 | ||||
|         $this->applyWithJoin(); | ||||
| 
 | ||||
|         if ($selectBridgeField && $relation->bridgeField) { | ||||
|             $this->repository->selectEntity($relation->bridge, $bridgeAlias, $bridgeAlias); | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user