From 40ac139fbe69b534d73099b403f355d552c22356 Mon Sep 17 00:00:00 2001 From: Afiq Hamzah Date: Sun, 11 Aug 2024 13:29:51 +0800 Subject: [PATCH] Fixed transaksi keuntungan query for TransactionOnlineTrail --- app/Http/Controllers/TransactionOnlineTrailController.php | 6 ++++-- app/TransaksiKeuntungan.php | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/TransactionOnlineTrailController.php b/app/Http/Controllers/TransactionOnlineTrailController.php index 8723995..c58413c 100644 --- a/app/Http/Controllers/TransactionOnlineTrailController.php +++ b/app/Http/Controllers/TransactionOnlineTrailController.php @@ -88,6 +88,9 @@ class TransactionOnlineTrailController extends Controller private function getTransaksiKeuntunganQuery($date, $request) { $transaksiKeuntungan = TransaksiKeuntungan::whereDate('tarikh_bayaran', $date) + ->whereHas('transaction', function ($query) { + return $query->where('teller', 'Online'); + }) ->when($request->filled('norujukan'), function ($query) use ($request) { return $query->where('norujukan', $request->norujukan); }) @@ -123,7 +126,7 @@ class TransactionOnlineTrailController extends Controller $connectionCawangan = Cawangan::on('mysql7')->whereIn('kodcaw', $cawanganTransactionOnline)->get()->pluck('mysql'); - $glDetail = $connectionCawangan->map(fn($x) => GlDetail::on($x)->where('teller', 'ONLINE')->whereDate('tarikh', $date)->get()) + $glDetail = $connectionCawangan->map(fn($x) => GlDetail::on($x)->where('teller', 'ONLINE')->whereDate('tarikh', $date)->orderBy('recno')->get()) ->flatten() ->when($isGroupByNorujukan, function ($glDetail) { return $glDetail->groupBy('descpt') @@ -135,7 +138,6 @@ class TransactionOnlineTrailController extends Controller ->when($request->filled('norujukan'), function ($glDetail) use ($request) { return $glDetail->filter(fn($x) => strpos($x->descpt, $request->norujukan) !== false); }) - ->sortKeysDesc() ->toArray(); return $glDetail; diff --git a/app/TransaksiKeuntungan.php b/app/TransaksiKeuntungan.php index 5692f89..316b4c1 100644 --- a/app/TransaksiKeuntungan.php +++ b/app/TransaksiKeuntungan.php @@ -23,4 +23,9 @@ class TransaksiKeuntungan extends Model * @var array */ // protected $hidden = []; -} \ No newline at end of file + + function transaction() + { + return $this->hasOne(Transaction::class, 'norujukan', 'norujukan'); + } +}