- 모델 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>
38 lines
900 B
PHP
38 lines
900 B
PHP
<?php
|
|
|
|
namespace App\Models\Stats;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class StatFinanceMonthly extends Model
|
|
{
|
|
protected $connection = 'sam_stat';
|
|
|
|
protected $table = 'stat_finance_monthly';
|
|
|
|
protected $casts = [
|
|
'stat_year' => 'integer',
|
|
'stat_month' => 'integer',
|
|
'deposit_total' => 'decimal:2',
|
|
'withdrawal_total' => 'decimal:2',
|
|
'net_cashflow' => 'decimal:2',
|
|
'bank_balance_end' => 'decimal:2',
|
|
'receivable_end' => 'decimal:2',
|
|
'payable_end' => 'decimal:2',
|
|
];
|
|
|
|
public function scopeForTenant($query, ?int $tenantId)
|
|
{
|
|
if ($tenantId) {
|
|
return $query->where('tenant_id', $tenantId);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function scopeForMonth($query, int $year, int $month)
|
|
{
|
|
return $query->where('stat_year', $year)->where('stat_month', $month);
|
|
}
|
|
}
|