Files
sam-manage/app/Models/Stats/StatProductionDaily.php
권혁성 5dd580623e feat:통계 대시보드 페이지 신규 구현 (/stats/dashboard)
- 모델 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>
2026-02-03 14:03:58 +09:00

42 lines
972 B
PHP

<?php
namespace App\Models\Stats;
use Illuminate\Database\Eloquent\Model;
class StatProductionDaily extends Model
{
protected $connection = 'sam_stat';
protected $table = 'stat_production_daily';
protected $casts = [
'stat_date' => 'date',
'production_qty' => 'decimal:2',
'defect_qty' => 'decimal:2',
'defect_rate' => 'decimal:2',
'efficiency_rate' => 'decimal:2',
'wo_created_count' => 'integer',
'wo_completed_count' => 'integer',
];
public function scopeForTenant($query, ?int $tenantId)
{
if ($tenantId) {
return $query->where('tenant_id', $tenantId);
}
return $query;
}
public function scopeForDateRange($query, string $from, string $to)
{
return $query->whereBetween('stat_date', [$from, $to]);
}
public function scopeForDate($query, string $date)
{
return $query->where('stat_date', $date);
}
}