Compare commits
No commits in common. "d4a9fc84634a7b4410d908a738b0594101c7851b" and "dcccce78932a8804f48db5b01c61c541ac0caeda" have entirely different histories.
d4a9fc8463
...
dcccce7893
@ -7,7 +7,7 @@ use Ulmus\Attribute\Attribute;
|
|||||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||||
class Relation {
|
class Relation {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Relation\RelationTypeEnum|string $type,
|
public string $type,
|
||||||
public \Stringable|string|array $key = "",
|
public \Stringable|string|array $key = "",
|
||||||
public null|\Closure $generateKey = null,
|
public null|\Closure $generateKey = null,
|
||||||
public null|\Stringable|string|array $foreignKey = null,
|
public null|\Stringable|string|array $foreignKey = null,
|
||||||
@ -29,6 +29,7 @@ class Relation {
|
|||||||
$this->bridgeField = Attribute::handleArrayField($this->bridgeField);
|
$this->bridgeField = Attribute::handleArrayField($this->bridgeField);
|
||||||
$this->bridgeForeignKey = Attribute::handleArrayField($this->bridgeForeignKey);
|
$this->bridgeForeignKey = Attribute::handleArrayField($this->bridgeForeignKey);
|
||||||
$this->field = Attribute::handleArrayField($this->field);
|
$this->field = Attribute::handleArrayField($this->field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entity() {
|
public function entity() {
|
||||||
@ -54,17 +55,17 @@ class Relation {
|
|||||||
|
|
||||||
public function isOneToOne() : bool
|
public function isOneToOne() : bool
|
||||||
{
|
{
|
||||||
return $this->type === Relation\RelationTypeEnum::oneToOne || $this->normalizeType() === 'onetoone';
|
return $this->normalizeType() === 'onetoone';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isOneToMany() : bool
|
public function isOneToMany() : bool
|
||||||
{
|
{
|
||||||
return $this->type === Relation\RelationTypeEnum::oneToMany || $this->normalizeType() === 'onetomany';
|
return $this->normalizeType() === 'onetomany';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isManyToMany() : bool
|
public function isManyToMany() : bool
|
||||||
{
|
{
|
||||||
return $this->type === Relation\RelationTypeEnum::manyToMany || $this->normalizeType() === 'manytomany';
|
return $this->normalizeType() === 'manytomany';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function function() : string
|
public function function() : string
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Ulmus\Attribute\Property\Relation;
|
|
||||||
|
|
||||||
enum RelationTypeEnum
|
|
||||||
{
|
|
||||||
case oneToOne;
|
|
||||||
case oneToMany;
|
|
||||||
case manyToMany;
|
|
||||||
}
|
|
@ -12,12 +12,7 @@ class Where {
|
|||||||
public mixed $value = null,
|
public mixed $value = null,
|
||||||
public string $operator = Query\Where::OPERATOR_EQUAL,
|
public string $operator = Query\Where::OPERATOR_EQUAL,
|
||||||
public string $condition = Query\Where::CONDITION_AND,
|
public string $condition = Query\Where::CONDITION_AND,
|
||||||
public null|\Stringable|array $foreignField = null,
|
|
||||||
) {
|
) {
|
||||||
$this->field = Attribute::handleArrayField($field);
|
$this->field = Attribute::handleArrayField($field);
|
||||||
|
|
||||||
if ($foreignField) {
|
|
||||||
$this->value = Attribute::handleArrayField($foreignField);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,11 +628,9 @@ class Repository
|
|||||||
$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->value, $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) {
|
foreach($this->entityResolver->searchFieldAnnotationList($item, [ Attribute\Property\Filter::class, Filter::class ] ) as $filter) {
|
||||||
call_user_func_array([ $this->entityClass, $filter->method ], [ $this, $item, true ]);
|
call_user_func_array([ $this->entityClass, $filter->method ], [ $this, $item, true ]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
||||||
@ -702,7 +700,7 @@ class Repository
|
|||||||
$repository = $entity::repository()->selectJsonEntity($entity, $alias)->open();
|
$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) {
|
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->value, $condition->operator);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user