- 모델 7개: StatSalesDaily, StatFinanceDaily, StatProductionDaily, StatInventoryDaily, StatSystemDaily, StatSalesMonthly, StatFinanceMonthly - DashboardStatService: 요약카드, 7일 추이차트, 알림, 월간요약 데이터 - StatDashboardController: HX-Redirect 패턴 적용 - 뷰: 요약카드 6개 + Chart.js 4개 차트 + 알림/월간요약 하단섹션 - 기존 대시보드 "통계 및 리포트" 바로가기 링크 연결 - 헤더 테넌트 선택 기준 전체/개별 테넌트 필터링 지원 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Stats;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\DashboardStatService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\View\View;
|
|
|
|
class StatDashboardController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly DashboardStatService $statService,
|
|
) {}
|
|
|
|
/**
|
|
* 통계 대시보드
|
|
*/
|
|
public function index(Request $request): View|Response
|
|
{
|
|
// Chart.js 스크립트가 @push('scripts')에 있으므로 HX-Redirect 필요
|
|
if ($request->header('HX-Request')) {
|
|
return response('', 200)->header('HX-Redirect', route('stats.dashboard'));
|
|
}
|
|
|
|
$tenantId = session('selected_tenant_id');
|
|
|
|
$summaryCards = $this->statService->getSummaryCards($tenantId);
|
|
$salesTrend = $this->statService->getSalesTrend($tenantId);
|
|
$financeTrend = $this->statService->getFinanceTrend($tenantId);
|
|
$productionTrend = $this->statService->getProductionTrend($tenantId);
|
|
$systemTrend = $this->statService->getSystemTrend($tenantId);
|
|
$recentAlerts = $this->statService->getRecentAlerts($tenantId);
|
|
$monthlySummary = $this->statService->getMonthlySummary($tenantId);
|
|
|
|
return view('stats.dashboard.index', compact(
|
|
'summaryCards',
|
|
'salesTrend',
|
|
'financeTrend',
|
|
'productionTrend',
|
|
'systemTrend',
|
|
'recentAlerts',
|
|
'monthlySummary',
|
|
));
|
|
}
|
|
}
|