[Dasboard Controller]

This commit is contained in:
Arief Dwi Wicaksono 2025-09-12 11:10:27 +07:00
parent 252f90aa41
commit 3697113b24
3 changed files with 35 additions and 9 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Kategori;
use App\Models\Template;
use App\Models\Pelanggan;
use Carbon\Carbon;
class DashboardController extends Controller
{
public function index()
{
$totalKategori = Kategori::count();
$totalTemplate = Template::count();
$totalPelanggan = Pelanggan::count();
$today = Carbon::now()->translatedFormat('l, d F Y');
// Pastikan nama view sesuai lokasi file blade-mu (admin.dashboard atau dashboard.index)
return view('admin.dashboard', compact(
'totalKategori',
'totalTemplate',
'totalPelanggan',
'today'
));
}
}

View File

@ -20,7 +20,7 @@
<div class="bg-white rounded-lg shadow-md p-4 flex justify-between items-center hover:shadow-lg transition-transform duration-300 transform hover:-translate-y-2">
<div>
<h5 class="text-gray-500 text-sm">Kategori</h5>
<h3 class="font-bold text-xl">10</h3>
<h3 class="font-bold text-xl">{{ $totalKategori }}</h3>
</div>
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
<i class="bi bi-diagram-3"></i>
@ -28,8 +28,8 @@
</div>
<div class="bg-white rounded-lg shadow-md p-4 flex justify-between items-center hover:shadow-lg transition-transform duration-300 transform hover:-translate-y-2">
<div>
<h5 class="text-gray-500 text-sm">Templat</h5>
<h3 class="font-bold text-xl">20</h3>
<h5 class="text-gray-500 text-sm">Template</h5>
<h3 class="font-bold text-xl">{{ $totalTemplate }}</h3>
</div>
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
<i class="bi bi-card-list"></i>
@ -38,7 +38,7 @@
<div class="bg-white rounded-lg shadow-md p-4 flex justify-between items-center hover:shadow-lg transition-transform duration-300 transform hover:-translate-y-2">
<div>
<h5 class="text-gray-500 text-sm">Pelanggan</h5>
<h3 class="font-bold text-xl">24</h3>
<h3 class="font-bold text-xl">{{ $totalPelanggan }}</h3>
</div>
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
<i class="bi bi-person"></i>
@ -51,4 +51,4 @@
Berhasil login sebagai <strong>{{ auth('admin')->user()->name }}</strong>
</div>
</div>
@endsection
@endsection

View File

@ -8,6 +8,7 @@ use App\Http\Controllers\TemplateController;
use App\Http\Controllers\PelangganController;
use App\Http\Controllers\Api\ReviewController;
use App\Models\Review;
use App\Http\Controllers\DashboardController;
// Redirect ke login admin
Route::get('/', function () {
@ -22,10 +23,7 @@ Route::prefix('admin')->name('admin.')->group(function () {
});
Route::middleware('auth:admin')->group(function () {
Route::get('/dashboard', function () {
return view('admin.dashboard');
})->name('dashboard');
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('logout');
});
});