added orderby and change pagination

This commit is contained in:
Hafifie PKB
2025-04-07 00:10:52 +08:00
parent 6509739737
commit abecbe4fa8
2 changed files with 13 additions and 1 deletions
@@ -20,6 +20,10 @@ class AutoSerahanController extends Controller
$perPage = $response['per_page'] ?? 10; // Items per page
$currentPage = $response['current_page'] ?? 1; // Current page
usort($items, function ($a, $b) {
return strtotime($b['created_at']) <=> strtotime($a['created_at']); // descending
});
$items = array_map(function ($item) {
$time_created = Carbon::parse($item['created_at']);
@@ -57,6 +61,10 @@ class AutoSerahanController extends Controller
$perPage = $response['per_page'] ?? 10; // Items per page
$currentPage = $response['current_page'] ?? 1; // Current page
usort($items, function ($a, $b) {
return strtotime($b['created_at']) <=> strtotime($a['created_at']); // descending
});
$items = array_map(function ($item) {
$time_created = Carbon::parse($item['created_at']);
@@ -90,6 +98,10 @@ class AutoSerahanController extends Controller
$perPage = $response['per_page'] ?? 10; // Items per page
$currentPage = $response['current_page'] ?? 1; // Current page
usort($items, function ($a, $b) {
return strtotime($b['created_at']) <=> strtotime($a['created_at']); // descending
});
$items = array_map(function ($item) {
$time_created = Carbon::parse($item['created_at']);