41 lines
1.5 KiB
PHP
41 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Carbon\Carbon;
|
|
use App\Models\Transactions;
|
|
use App\Models\Transaction;
|
|
use App\Models\Refund;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class AdminDashboardController extends Controller
|
|
{
|
|
public function index(){
|
|
$sumSettlement = 0;
|
|
$sumCancelled = 0;
|
|
$sumRefund = 0;
|
|
$currentYear = Carbon::now()->year;
|
|
$dataChartTransaction = [];
|
|
$dataChartRefund = [];
|
|
for($bulan = 1; $bulan <= 12; $bulan++){
|
|
$transaction = Transaction::whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total_bayar');
|
|
// $transaction = Transaction::where('status','finished')->whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total_bayar');
|
|
// $refund = Refund::whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total');
|
|
// $refund = Refund::where('status','Partial Refund')->whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total');
|
|
$dataChartTransaction[] = intval($transaction);
|
|
// $dataChartRefund[] = intval($refund);
|
|
}
|
|
return view('admin.index',[
|
|
"transaction"=>Transactions::allTransactions(),
|
|
"dataChartTransaction" => $dataChartTransaction,
|
|
// "dataChartRefund" => $dataChartRefund
|
|
]);
|
|
}
|
|
|
|
public function profile(){
|
|
return view('admin.profile.index');
|
|
}
|
|
}
|