feat: add dashboard
This commit is contained in:
parent
4b3ffb10ff
commit
f117e708a6
@ -2,12 +2,38 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PatienRegistration;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard');
|
||||
// Count all patients registered for hospital service
|
||||
$patient_register_today = PatienRegistration::whereDate('created_at', now())->count();
|
||||
$patient_register_month = PatienRegistration::whereMonth('created_at', now()->month)->count();
|
||||
|
||||
// revenue today
|
||||
$todayRevenue = Transaction::select(DB::raw('SUM(treatments.fee * transactions.amount) as total'))
|
||||
->join('treatments', 'transactions.treatment_id', '=', 'treatments.id')
|
||||
->whereDate('transactions.created_at', Carbon::today())
|
||||
->value('total');
|
||||
|
||||
// Revenue for last month
|
||||
$lastMonthRevenue = Transaction::select(DB::raw('SUM(treatments.fee * transactions.amount) as total'))
|
||||
->join('treatments', 'transactions.treatment_id', '=', 'treatments.id')
|
||||
->whereYear('transactions.created_at', now()->year)
|
||||
->whereMonth('transactions.created_at', now()->month)
|
||||
->value('total');
|
||||
|
||||
return view('dashboard', [
|
||||
'title' => 'Dashboard',
|
||||
'patient_register_today' => $patient_register_today,
|
||||
'patiet_register_month' => $patient_register_month,
|
||||
'todayRevenue' => $todayRevenue,
|
||||
'lastMonthRevenue' => $lastMonthRevenue,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,14 +26,13 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3>50</h3>
|
||||
<h3>{{ $patient_register_today }}</h3>
|
||||
|
||||
<p>Surat Masuk</p>
|
||||
<p>Pasian Hari Ini</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-stats-bars"></i>
|
||||
</div>
|
||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
@ -41,14 +40,13 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-success">
|
||||
<div class="inner">
|
||||
<h3>100</h3>
|
||||
<h3>{{ $patiet_register_month }}</h3>
|
||||
|
||||
<p>Surat Keluar</p>
|
||||
<p>Pasien Sebulan Terakhir</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-stats-bars"></i>
|
||||
</div>
|
||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
@ -56,14 +54,13 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-warning">
|
||||
<div class="inner">
|
||||
<h3>5</h3>
|
||||
<h3>Rp. {{ number_format($todayRevenue) }}</h3>
|
||||
|
||||
<p>Jenis Surat</p>
|
||||
<p>Pendapatan Harian</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-document-text"></i>
|
||||
<i class="ion ion-cash"></i>
|
||||
</div>
|
||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
@ -71,14 +68,13 @@
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-danger">
|
||||
<div class="inner">
|
||||
<h3>3</h3>
|
||||
<h3>Rp. {{ number_format($lastMonthRevenue) }}</h3>
|
||||
|
||||
<p>Pengguna Sistem</p>
|
||||
<p>Pendapatan Bulanan</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-person"></i>
|
||||
</div>
|
||||
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user