Perbaiki dashboard admin

This commit is contained in:
Muhammad Raihan Surya 2023-11-06 14:52:21 +07:00
parent 9600ed71f1
commit ceb5cf414e
2 changed files with 22 additions and 14 deletions

View File

@ -19,22 +19,22 @@ class AdminDashboardController extends Controller
$currentMonth = Carbon::now()->month;
$currentYear = Carbon::now()->year;
$countSuccess = Transaction::where('status', 'settlement')
$countSuccess = Transaction::where('status_pembayaran', 'settlement')
->whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count();
$countPending = Transaction::where('status', 'pending')
$countPending = Transaction::where('status_pembayaran', 'pending')
->whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count();
$countCancelled = Transaction::where('status', 'cancel')
$countCancelled = Transaction::where('status_pembayaran', 'cancel')
->whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count();
$countRefund = Transaction::where('status', 'refund')
$countRefund = Transaction::where('status_pembayaran', 'refund')
->whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count();
@ -46,7 +46,7 @@ class AdminDashboardController extends Controller
$dataChartTransaction = [];
$dataChartRefund = [];
$totalRefund = Transaction::where('status', 'refund')->count();
$totalRefund = Transaction::where('status_pembayaran', 'refund')->count();
$dataChartTotalRefund = [];
$totalUser = User::where('status', 'Finished')->count();
@ -55,12 +55,12 @@ class AdminDashboardController extends Controller
for ($bulan = 1; $bulan <= 12; $bulan++) {
$transaction = Transaction::whereMonth('updated_at', $bulan)
->whereYear('updated_at', $currentYear)
->where('status', 'settlement')
->where('status_pembayaran', 'settlement')
->sum('total_bayar');
$refund = Transaction::whereMonth('updated_at', $bulan)
->whereYear('updated_at', $currentYear)
->where('status', 'partial refund')
->where('status_pembayaran', 'refund')
->sum('total_harga');
$dataChartTransaction[] = intval($transaction);

View File

@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Ramsey\Uuid\Uuid;
use GuzzleHttp\Client;
use Stichoza\GoogleTranslate\GoogleTranslate;
use Throwable;
@ -194,15 +195,23 @@ class UserTransactionController extends Controller
'enabled_payments' => ['credit_card', 'gopay', 'qris'],
];
$client = new Client();
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => "Basic $auth",
])->post('https://app.sandbox.midtrans.com/snap/v1/transactions', $params);
$response = $client->request('POST', 'https://app.sandbox.midtrans.com/snap/v1/transactions', [
'body' => json_encode($params),
'headers' => [
'accept' => 'application/json',
'authorization' => 'Basic '.$auth,
'content-type' => 'application/json',
],
]);
$result = $response->getBody();
Transaction::where('id', $query->id)->update([
'token' => $response['token'],
'token' => $result['token'],
]);
$contact = Contact::where('pemilik_kontak', $pembeli)
@ -561,11 +570,10 @@ class UserTransactionController extends Controller
$result = json_decode($response->body(), true);
try {
DB::beginTransaction();
Transaction::where('id', $request->id)->update([
'status_pembayaran' => $result['transaction_status']
'status_pembayaran' => $result['transaction_status'],
]);
DB::commit();