Show "from" value in logs when not explicitely set

It was empty before, and it looked like there are no logs. But they were just filtered for the last 7 days.

[MAILPOET-5670]
This commit is contained in:
 Ján Mikláš
2024-08-09 21:54:43 +02:00
committed by Jan Jakeš
parent 8ea0482ed8
commit 9feb0433e6
3 changed files with 7 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ class Logs {
$offset = isset($_GET['offset']) ? sanitize_text_field(wp_unslash($_GET['offset'])) : null;
$limit = isset($_GET['limit']) ? sanitize_text_field(wp_unslash($_GET['limit'])) : null;
$dateFrom = (new Carbon())->subDays(7);
$defaultFrom = $dateFrom->format('Y-m-d');
if (isset($from)) {
$dateFrom = new Carbon($from);
}
@@ -38,6 +39,7 @@ class Logs {
$logs = $this->logRepository->getLogs($dateFrom, $dateTo, $search, $offset, $limit);
$data = [
'logs' => [],
'logs_default_from' => $defaultFrom,
];
foreach ($logs as $log) {
$data['logs'][] = [