mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-24 07:08:40 +00:00
cleanup
This commit is contained in:
parent
e952b515d8
commit
090b30bb58
|
|
@ -2955,51 +2955,6 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
return !empty(static::$createdAt) ? static::$createdAt : static::$primaryField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model based on request object
|
||||
*
|
||||
* @todo: change to graphql
|
||||
*
|
||||
* @param RequestAbstract $request Request object
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getByRequest(RequestAbstract $request)
|
||||
{
|
||||
if ($request->getData('id') !== null) {
|
||||
$result = static::get((int) $request->getData('id'));
|
||||
} elseif (($filter = ((string) $request->getData('filter'))) !== null) {
|
||||
$filter = \strtolower($filter);
|
||||
|
||||
if ($filter === 'all') {
|
||||
$result = static::getAll();
|
||||
} elseif ($filter === 'list') {
|
||||
$list = $request->getData('list');
|
||||
$result = static::get(\json_decode($list, true));
|
||||
} else {
|
||||
$limit = (int) ($request->getData('limit') ?? 1);
|
||||
$from = $request->getData('from') === null ? null : new \DateTime((string) $request->getData('from'));
|
||||
$to = $request->getData('to') === null ? null : new \DateTime((string) $request->getData('to'));
|
||||
|
||||
$query = static::getQuery();
|
||||
$query->limit($limit);
|
||||
|
||||
if (isset($from, $to) && !empty(static::getCreatedAt())) {
|
||||
$query->where(static::getCreatedAt(), '>=', $from);
|
||||
$query->where(static::getCreatedAt(), '<=', $to);
|
||||
}
|
||||
|
||||
$result = static::getAllByQuery($query);
|
||||
}
|
||||
} else {
|
||||
return self::getNullModelObj();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add initialized object to local cache
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user