From 1860cb111c6ba45dba45aca275f16564e3daecd4 Mon Sep 17 00:00:00 2001 From: oktaviaramadani Date: Mon, 27 Nov 2023 11:46:29 +0700 Subject: [PATCH] perubahan dashboard --- .../Dashboard/UserDashboardController.php | 25 ++++++++++++++++--- resources/views/User/index.blade.php | 21 ++++++++-------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/User/Dashboard/UserDashboardController.php b/app/Http/Controllers/User/Dashboard/UserDashboardController.php index 28b5067..7e377c0 100644 --- a/app/Http/Controllers/User/Dashboard/UserDashboardController.php +++ b/app/Http/Controllers/User/Dashboard/UserDashboardController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\User\Dashboard; use App\Http\Controllers\Controller; +use App\Models\Refund; use Illuminate\Http\Request; use App\Models\RefundUser; use App\Models\Transaction; @@ -38,11 +39,29 @@ class UserDashboardController extends Controller ->where('pembeli', auth()->user()->email) ->count(); - $sumRefund = ''; + $sumRefund = Transaction::join('refunds', 'transactions.id', '=', 'refunds.transaction_id') + ->where('transactions.status_pembayaran', 'refund') + ->whereMonth('transactions.updated_at', $currentMonth) + ->whereYear('transactions.updated_at', $currentYear) + ->where('transactions.pembeli', auth()->user()->email) + ->sum('refunds.total'); - $sumTransaksi = ''; + $sumTransaksi = Transaction::whereMonth('updated_at', $currentMonth) + ->whereYear('updated_at', $currentYear) + ->where('pembeli', auth()->user()->email) + ->sum('total_bayar'); - return view('user.index'); + $totalTransaction = Transaction::whereMonth('updated_at', $currentMonth) + ->whereYear('updated_at', $currentYear) + ->count(); + + $totalIncome = Transaction::where('status_transaksi', 'success')->sum('total_bayar'); + + $totalExpense = Transaction::where('status_transaksi', 'updated_at') + ->orWhere('status_transaksi', 'refund') + ->sum('total_bayar'); + + return view('user.index', compact('currentRole', 'countCreated', 'countPending', 'countFailure', 'sumRefund', 'sumTransaksi', 'totalTransaction', 'totalIncome', 'totalExpense')); } public function getSelectedChart(){ diff --git a/resources/views/User/index.blade.php b/resources/views/User/index.blade.php index 1b568ed..36b335c 100644 --- a/resources/views/User/index.blade.php +++ b/resources/views/User/index.blade.php @@ -56,25 +56,26 @@
-
114
+
{{ $countCreated }}
Dibuat
-
12
+
{{ $countPending }}
Pending
-
23
+
{{ $countFailure }}
Gagal
-
23
-
Gagal
+
{{ $sumRefund }}
+
Refund
-
23
-
Gagal
+
{{ $sumTransaksi }}
+
Transaksi
+
@@ -85,7 +86,7 @@

Jumlah Transaction

- 159 Transaksi + {{ $totalTransaction }}
@@ -103,7 +104,7 @@

Pemasukan

- Rp. 35.000.000,00 + Rp. {{ number_format($totalIncome, 2) }}
@@ -120,7 +121,7 @@

Pengeluaran

-
Rp. 35.000.000,00
+
Rp. {{ number_format($totalExpense, 2) }}