feat:자금계획일정 달력에 휴일 표시 적용
holidays 테이블에서 휴일 조회하여 달력에 빨간색 배경 + 휴일명 표시 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Finance\BankAccount;
|
||||
use App\Models\Finance\FundSchedule;
|
||||
use App\Models\System\Holiday;
|
||||
use App\Services\FundScheduleService;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -37,12 +38,17 @@ public function index(): View|Response
|
||||
// 계좌 목록 (필터용)
|
||||
$accounts = BankAccount::active()->ordered()->get(['id', 'bank_name', 'account_number']);
|
||||
|
||||
// 휴일 데이터 (달력 표시용)
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
$holidayMap = $this->getHolidayMap($tenantId, $year, $month);
|
||||
|
||||
return view('finance.fund-schedules.index', compact(
|
||||
'year',
|
||||
'month',
|
||||
'calendarData',
|
||||
'summary',
|
||||
'accounts'
|
||||
'accounts',
|
||||
'holidayMap'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -106,4 +112,30 @@ public function show(int $id): View
|
||||
|
||||
return view('finance.fund-schedules.show', compact('schedule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 해당 월의 휴일 맵 생성 (날짜 => 휴일명)
|
||||
*/
|
||||
private function getHolidayMap(int $tenantId, int $year, int $month): array
|
||||
{
|
||||
$startOfMonth = \Carbon\Carbon::create($year, $month, 1)->startOfWeek(\Carbon\Carbon::SUNDAY);
|
||||
$endOfMonth = \Carbon\Carbon::create($year, $month, 1)->endOfMonth()->endOfWeek(\Carbon\Carbon::SATURDAY);
|
||||
|
||||
$holidays = Holiday::forTenant($tenantId)
|
||||
->where('start_date', '<=', $endOfMonth->toDateString())
|
||||
->where('end_date', '>=', $startOfMonth->toDateString())
|
||||
->get();
|
||||
|
||||
$map = [];
|
||||
foreach ($holidays as $holiday) {
|
||||
$start = $holiday->start_date->copy();
|
||||
$end = $holiday->end_date->copy();
|
||||
for ($d = $start; $d->lte($end); $d->addDay()) {
|
||||
$key = $d->format('Y-m-d');
|
||||
$map[$key] = $holiday->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user