Add sort column to account overview. and some css fixes

This commit is contained in:
James Cole
2024-03-24 13:24:48 +01:00
parent 46c49ddbd8
commit 538933691e
5 changed files with 55 additions and 37 deletions

View File

@@ -137,6 +137,17 @@ class AccountTransformer extends AbstractTransformer
return $rightBalance <=> $leftBalance;
});
}
if ('last_activity' === $column) {
$dates = $this->lastActivity;
$objects = $objects->sort(function (Account $left, Account $right) use ($dates, $direction) {
$leftDate = $dates[$left->id] ?? Carbon::create(1900, 1, 1, 0, 0, 0);
$rightDate = $dates[$right->id] ?? Carbon::create(1900, 1, 1, 0, 0, 0);
if ('asc' === $direction) {
return $leftDate->gt($rightDate) ? 1 : -1;
}
return $rightDate->gt($leftDate) ? 1 : -1;
});
}
}
}