- Added some attributes-related manipulation in SearchRequest trait

- Removed default page setting based on query params adn
- Added DateTime format doc
This commit is contained in:
mcndave committed 2026-10-27 18:17:21 +00:00
1 parent ec061bcd9f
commit 75fb7ba155
3 files changed
+86 -4

No files matched your search

@@ -61,7 +61,8 @@ trait SearchRequestFromRequestTrait
{
$this->objectReflection = ObjectReflection::fromClass(static::class)->reflectClass();
$this->page = $data['page'] ?? 1;
# REMOVED - this could cause legacy problems, kept in case of a quick uncomment is needed
# $this->page = $data['page'] ?? 1;
$this->applyValues(
fn($propertyName, $attribute) => $data[$propertyName] ?? null
@@ -86,9 +87,9 @@ trait SearchRequestFromRequestTrait
$this->prepare($request);
}
$queryParams = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return ! is_null($i) && $i !== ""; }));
$this->page = $queryParams->offsetExists('page') ? $queryParams['page'] : 1;
# REMOVED - this could cause legacy problems, kept in case of a quick uncomment is needed
# $queryParams = new \ArrayObject(array_filter($request->getQueryParams(), function($i) { return ! is_null($i) && $i !== ""; }));
# $this->page = $queryParams->offsetExists('page') ? $queryParams['page'] : 1;
$this->applyValues(
fn($propertyName, $attribute) =>$this->getValueFromSource($request, $propertyName, $attribute)
@@ -155,6 +156,21 @@ trait SearchRequestFromRequestTrait
}
}
public function getPropertyAttribute(string $name) : ? Attribute\SearchParameter
{
foreach($this->objectReflection->getProperties() as $propertyName => $property) {
if ($propertyName === $name) {
$attribute = $property->getAttribute(Attribute\SearchParameter::class)->object ?? false;
if ($attribute) {
return $attribute;
}
}
}
return null;
}
protected function applyValues(\Closure $getValue) : void
{
foreach($this->objectReflection->getProperties() as $propertyName => $property) {