- Merged
This commit is contained in:
parent
2d86adc3e1
commit
1e4a528d39
@ -317,7 +317,7 @@ trait EntityTrait {
|
|||||||
$alias = $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : $default;
|
$alias = $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : $default;
|
||||||
|
|
||||||
return new EntityField(
|
return new EntityField(
|
||||||
entityClass: static::class, name: $name, alias: $alias, entityResolver: Ulmus::resolveEntity(static::class), select: $select
|
name: $name, entityClass: static::class, alias: $alias, entityResolver: Ulmus::resolveEntity(static::class), select: $select
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class Repository implements RepositoryInterface
|
|||||||
|
|
||||||
public array $events = [];
|
public array $events = [];
|
||||||
|
|
||||||
public ? ConnectionAdapter $adapters;
|
public ? ConnectionAdapter $adapter;
|
||||||
|
|
||||||
public readonly QueryBuilder\QueryBuilderInterface $queryBuilder;
|
public readonly QueryBuilder\QueryBuilderInterface $queryBuilder;
|
||||||
|
|
||||||
@ -31,7 +31,8 @@ class Repository implements RepositoryInterface
|
|||||||
|
|
||||||
protected array $joined = [];
|
protected array $joined = [];
|
||||||
|
|
||||||
public function __construct(string $entity, string $alias = self::DEFAULT_ALIAS, ?ConnectionAdapter $adapter = null) {
|
public function __construct(string $entity, string $alias = self::DEFAULT_ALIAS, null|ConnectionAdapter $adapter = null) {
|
||||||
|
|
||||||
$this->entityClass = $entity;
|
$this->entityClass = $entity;
|
||||||
$this->alias = $alias;
|
$this->alias = $alias;
|
||||||
$this->entityResolver = Ulmus::resolveEntity($entity);
|
$this->entityResolver = Ulmus::resolveEntity($entity);
|
||||||
@ -465,8 +466,8 @@ class Repository implements RepositoryInterface
|
|||||||
foreach(array_filter($fields, fn($e) => $e && ! isset($this->joined[$e]) ) as $item) {
|
foreach(array_filter($fields, fn($e) => $e && ! isset($this->joined[$e]) ) as $item) {
|
||||||
$this->joined[$item] = true;
|
$this->joined[$item] = true;
|
||||||
|
|
||||||
$attribute = $this->entityResolver->searchFieldAnnotation($item, [ Join::class ]) ?:
|
$attribute = clone ($this->entityResolver->searchFieldAnnotation($item, [ Join::class ]) ?:
|
||||||
$this->entityResolver->searchFieldAnnotation($item, [ Relation::class ]);
|
$this->entityResolver->searchFieldAnnotation($item, [ Relation::class ]));
|
||||||
|
|
||||||
$isRelation = $attribute instanceof Relation;
|
$isRelation = $attribute instanceof Relation;
|
||||||
|
|
||||||
@ -476,8 +477,7 @@ class Repository implements RepositoryInterface
|
|||||||
|
|
||||||
if ( $attribute ) {
|
if ( $attribute ) {
|
||||||
$alias = $attribute->alias ?? $item;
|
$alias = $attribute->alias ?? $item;
|
||||||
|
$entity = $attribute->entity ?? $this->entityResolver->getPropertyEntityType($item);
|
||||||
$entity = $attribute->entity ?? $this->entityResolver->reflectedClass->getProperties(true)[$item]->getTypes()[0]->type;
|
|
||||||
|
|
||||||
foreach($entity::resolveEntity()->fieldList(Common\EntityResolver::KEY_COLUMN_NAME, true) as $key => $field) {
|
foreach($entity::resolveEntity()->fieldList(Common\EntityResolver::KEY_COLUMN_NAME, true) as $key => $field) {
|
||||||
if ( null === $entity::resolveEntity()->searchFieldAnnotation($field->name, [ Relation\Ignore::class ]) ) {
|
if ( null === $entity::resolveEntity()->searchFieldAnnotation($field->name, [ Relation\Ignore::class ]) ) {
|
||||||
|
|||||||
@ -207,7 +207,6 @@ class RelationBuilder
|
|||||||
return new $class();
|
return new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function instanciateEmptyObject(string $name, Relation|Join $relation) : object
|
protected function instanciateEmptyObject(string $name, Relation|Join $relation) : object
|
||||||
{
|
{
|
||||||
switch( true ) {
|
switch( true ) {
|
||||||
|
|||||||
@ -169,6 +169,14 @@ trait SearchRequestFromRequestTrait
|
|||||||
$this->parseAttributeGroupBy($attribute, $field, $propertyName);
|
$this->parseAttributeGroupBy($attribute, $field, $propertyName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case $attribute instanceof SearchOrderBy:
|
||||||
|
if ($value !== null) {
|
||||||
|
$this->$propertyName = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->parseAttributeOrderBy($attribute, $field, $propertyName);
|
||||||
|
break;
|
||||||
|
|
||||||
case $attribute instanceof SearchWhere:
|
case $attribute instanceof SearchWhere:
|
||||||
case $attribute instanceof SearchLike:
|
case $attribute instanceof SearchLike:
|
||||||
case $attribute instanceof SearchManual:
|
case $attribute instanceof SearchManual:
|
||||||
@ -198,14 +206,6 @@ trait SearchRequestFromRequestTrait
|
|||||||
|
|
||||||
$this->parseAttributeMethod($attribute, $field, $propertyName);
|
$this->parseAttributeMethod($attribute, $field, $propertyName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case $attribute instanceof SearchOrderBy:
|
|
||||||
if ($value !== null) {
|
|
||||||
$this->$propertyName = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->parseAttributeOrderBy($attribute, $field, $propertyName);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,6 @@ trait SearchRequestFromRequestTrait
|
|||||||
if (! isset($this->$propertyName)) {
|
if (! isset($this->$propertyName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($attribute->method) {
|
switch ($attribute->method) {
|
||||||
case SearchMethodEnum::Like:
|
case SearchMethodEnum::Like:
|
||||||
case SearchMethodEnum::LikeLeft:
|
case SearchMethodEnum::LikeLeft:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user