fix: [instance:searchAll] Get the correct count if after filter is applied

pull/93/head
Sami Mokaddem 2022-02-28 14:34:14 +01:00
parent 8450e83607
commit bc04fd0336
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 4 additions and 1 deletions

View File

@ -124,13 +124,16 @@ class InstanceTable extends AppTable
if (!empty($tableConfig['contain'])) {
$query->contain($tableConfig['contain']);
}
$results[$tableName]['amount'] = $query->count();
if (empty($tableConfig['afterFind'])) {
$results[$tableName]['amount'] = $query->count();
}
$result = $query->limit($limit)->all()->toList();
if (!empty($result)) {
if (!empty($tableConfig['afterFind'])) {
$result = $tableConfig['afterFind']($result, $user);
}
$results[$tableName]['entries'] = $result;
$results[$tableName]['amount'] = count($result);
}
}
return $results;