[Dasboard Controller]
This commit is contained in:
parent
252f90aa41
commit
3697113b24
28
backend/app/Http/Controllers/DashboardController.php
Normal file
28
backend/app/Http/Controllers/DashboardController.php
Normal 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'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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 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>
|
<div>
|
||||||
<h5 class="text-gray-500 text-sm">Kategori</h5>
|
<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>
|
||||||
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
|
<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>
|
<i class="bi bi-diagram-3"></i>
|
||||||
@ -28,8 +28,8 @@
|
|||||||
</div>
|
</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 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>
|
<div>
|
||||||
<h5 class="text-gray-500 text-sm">Templat</h5>
|
<h5 class="text-gray-500 text-sm">Template</h5>
|
||||||
<h3 class="font-bold text-xl">20</h3>
|
<h3 class="font-bold text-xl">{{ $totalTemplate }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
|
<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>
|
<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 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>
|
<div>
|
||||||
<h5 class="text-gray-500 text-sm">Pelanggan</h5>
|
<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>
|
||||||
<div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center text-xl">
|
<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>
|
<i class="bi bi-person"></i>
|
||||||
@ -51,4 +51,4 @@
|
|||||||
Berhasil login sebagai <strong>{{ auth('admin')->user()->name }}</strong>
|
Berhasil login sebagai <strong>{{ auth('admin')->user()->name }}</strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use App\Http\Controllers\TemplateController;
|
|||||||
use App\Http\Controllers\PelangganController;
|
use App\Http\Controllers\PelangganController;
|
||||||
use App\Http\Controllers\Api\ReviewController;
|
use App\Http\Controllers\Api\ReviewController;
|
||||||
use App\Models\Review;
|
use App\Models\Review;
|
||||||
|
use App\Http\Controllers\DashboardController;
|
||||||
|
|
||||||
// Redirect ke login admin
|
// Redirect ke login admin
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
@ -22,10 +23,7 @@ Route::prefix('admin')->name('admin.')->group(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware('auth:admin')->group(function () {
|
Route::middleware('auth:admin')->group(function () {
|
||||||
Route::get('/dashboard', function () {
|
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||||
return view('admin.dashboard');
|
|
||||||
})->name('dashboard');
|
|
||||||
|
|
||||||
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('logout');
|
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('logout');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user