diff --git a/app/Services/BillplzService.php b/app/Services/BillplzService.php index 68f25cb..74d665a 100644 --- a/app/Services/BillplzService.php +++ b/app/Services/BillplzService.php @@ -3,6 +3,7 @@ namespace App\Services; use Billplz\Client; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; @@ -93,7 +94,13 @@ class BillplzService public function getBillplzTransactionReview($date) { + $date = Carbon::now()->subDays(8)->toDateString(); $arrahnTransactions = $this->getArrahnTransactions($date); + + // sort array by tarikh desc and masa key desc + array_multisort(array_column($arrahnTransactions, 'tarikh'), SORT_DESC, array_column($arrahnTransactions, 'masa'), SORT_DESC, $arrahnTransactions); + + $arrahnTransactionsGroupedByBill = collect($arrahnTransactions)->groupBy('billplz_id'); $billplzID = $arrahnTransactionsGroupedByBill->keys(); $billplzTransactions = $this->getTransactions($date);