store/app/Http/Controllers/Admin/DashboardController.php

50 lines
2.4 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Services\System\DashboardService;
use Carbon\Carbon;
use Inertia\Inertia;
use Inertia\Response;
class DashboardController extends Controller
{
public function __construct(
private readonly DashboardService $dashboardService,
) {}
public function index(): Response
{
$now = Carbon::now();
$startOfMonth = $now->copy()->startOfMonth();
$endOfMonth = $now->copy()->endOfMonth();
return Inertia::render('admin/Dashboard', [
'rawMaterialStock' => $this->dashboardService->getRawMaterialStock(),
'productStock' => $this->dashboardService->getProductStock(),
'lowStockProducts' => $this->dashboardService->getLowStockProducts(),
'lowStockMaterials' => $this->dashboardService->getLowStockMaterials(),
'topSuppliers' => $this->dashboardService->getTopSuppliers(),
'topCustomers' => $this->dashboardService->getTopCustomers(),
'topProducts' => $this->dashboardService->getTopProducts(),
'purchaseSummary' => $this->dashboardService->getPurchaseSummary(),
'cuttingSummary' => $this->dashboardService->getCuttingSummary(),
'cuttingByStatus' => $this->dashboardService->getCuttingByStatus(),
'orderStats' => $this->dashboardService->getOrderStats(),
'revenueSummary' => $this->dashboardService->getRevenueSummary(),
'marketplaceSummary' => $this->dashboardService->getMarketplaceSummary(),
'cashAccounts' => $this->dashboardService->getCashAccounts(),
'monthlyCashFlow' => $this->dashboardService->getMonthlyCashFlow(),
'monthlyExpenses' => $this->dashboardService->getMonthlyExpenses($startOfMonth, $endOfMonth),
'kasbonSummary' => $this->dashboardService->getKasbonSummary(),
'payrollSummary' => $this->dashboardService->getPayrollSummary($startOfMonth, $endOfMonth),
'leaveRequestSummary' => $this->dashboardService->getLeaveRequestSummary($startOfMonth, $endOfMonth),
'employeeSummary' => $this->dashboardService->getEmployeeSummary(),
'attendanceToday' => $this->dashboardService->getAttendanceToday(),
'monthlyRevenueTrend' => $this->dashboardService->getMonthlyRevenueTrend(),
'monthlyPurchaseTrend' => $this->dashboardService->getMonthlyPurchaseTrend(),
]);
}
}