- 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)]
|
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
|
||||||
class WithJoin {
|
class WithJoin {
|
||||||
public function __construct(
|
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
|
protected function instanciateEmptyEntity(string $name, Relation $relation) : object
|
||||||
{
|
{
|
||||||
$class = $relation->entity ?? $this->resolver->reflectedClass->getProperties()[$name]->getTypes()[0]->type;
|
$class = $relation->entity ?? $this->resolver->reflectedClass->getProperties()[$name]->getTypes()[0]->type;
|
||||||
@ -270,6 +277,8 @@ class RelationBuilder
|
|||||||
|
|
||||||
$this->applyOrderBy();
|
$this->applyOrderBy();
|
||||||
|
|
||||||
|
$this->applyWithJoin();
|
||||||
|
|
||||||
$field = $relation->key;
|
$field = $relation->key;
|
||||||
|
|
||||||
if ($relation->foreignKey) {
|
if ($relation->foreignKey) {
|
||||||
@ -313,6 +322,8 @@ class RelationBuilder
|
|||||||
|
|
||||||
$this->applyOrderBy();
|
$this->applyOrderBy();
|
||||||
|
|
||||||
|
$this->applyWithJoin();
|
||||||
|
|
||||||
if ($selectBridgeField && $relation->bridgeField) {
|
if ($selectBridgeField && $relation->bridgeField) {
|
||||||
$this->repository->selectEntity($relation->bridge, $bridgeAlias, $bridgeAlias);
|
$this->repository->selectEntity($relation->bridge, $bridgeAlias, $bridgeAlias);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user