added orderby and change pagination
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user