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']);
@@ -15,7 +15,7 @@
@foreach($list as $item)
<tbody>
<tr>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">{{ $item['id'] }}</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">{{ ($list->currentPage() - 1) * $list->perPage() + $loop->iteration }}</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">{{ $item['cawangan_name'] }}</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">{{ $item['tarikh'] }}</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">{{ $item['masa'] }}</td>