41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Koleksi;
|
|
use App\Models\Anggota;
|
|
use App\Models\BorrowTransaction;
|
|
use Carbon\Carbon;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$totalBuku = Koleksi::count();
|
|
$totalAnggota = Anggota::count();
|
|
|
|
$peminjamanAktif = BorrowTransaction::whereNull('tanggal_kembali')->count();
|
|
$pengembalian = BorrowTransaction::whereNotNull('tanggal_kembali')
|
|
->whereBetween('tanggal_kembali', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])
|
|
->count();
|
|
|
|
$bulan = ['Jun','Jul','Agt','Sep','Okt','Nov','Des'];
|
|
$jumlahTransaksi = [];
|
|
foreach($bulan as $bln){
|
|
$count = BorrowTransaction::whereMonth('created_at', date('m', strtotime($bln.' 1')))->count();
|
|
$jumlahTransaksi[] = $count;
|
|
}
|
|
|
|
return view('dashboard.index', compact(
|
|
'totalBuku',
|
|
'totalAnggota',
|
|
'peminjamanAktif',
|
|
'pengembalian',
|
|
'bulan',
|
|
'jumlahTransaksi'
|
|
));
|
|
}
|
|
}
|
|
|