- Work done on search request mostly
This commit is contained in:
1 parent
f938e18572
commit
7b35de3258
7 files changed
+26
-14
No files matched your search
@@ -7,6 +7,7 @@ use Ulmus\Query;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
|
||||
class Where {
|
||||
|
||||
public function __construct(
|
||||
public string|\Stringable|array $field,
|
||||
public mixed $value = null,
|
||||
@@ -21,18 +22,23 @@ class Where {
|
||||
|
||||
public function getValue(/* null|EntityInterface */ $entity = null) : mixed
|
||||
{
|
||||
if ($this->generateValue) {
|
||||
if ($entity) {
|
||||
if ($entity) {
|
||||
if ($this->generateValue) {
|
||||
return call_user_func_array($this->generateValue, [ $entity ]);
|
||||
}
|
||||
else {
|
||||
elseif ($this->fieldValue) {
|
||||
throw new \Exception(sprintf("Field value, from %s, could not be included in query since the entity is already loaded; it is meant to be used with a OneToOne relation loaded within a join.", (string) $this->fieldValue));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->fieldValue) {
|
||||
return $this->fieldValue;
|
||||
}
|
||||
elseif ($this->generateValue) {
|
||||
throw new \Exception(sprintf("Could not generate value from non-instanciated entity for field %s.", (string) $this->field));
|
||||
}
|
||||
}
|
||||
elseif ($this->fieldValue && $entity) {
|
||||
throw new \Exception(sprintf("Field value, from %s, could not be included in query since the entity is already loaded; it is meant to be used with a OneToOne relation loaded within a join.", (string) $this->fieldValue));
|
||||
}
|
||||
|
||||
return $this->fieldValue ?? $this->value;
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user