@props([ 'month' => null, 'year' => null, 'events' => [], ]) @php $month = $month ?? now()->month; $year = $year ?? now()->year; $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); $firstDayOfWeek = (int) date('N', mktime(0, 0, 0, $month, 1, $year)); $today = now()->day; $isCurrentMonth = now()->month === $month && now()->year === $year; $dayHeaders = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']; @endphp
@foreach($dayHeaders as $header)
{{ $header }}
@endforeach @for($i = 1; $i < $firstDayOfWeek; $i++) @endfor @for($day = 1; $day <= $daysInMonth; $day++) @php $classes = collect(['bv-calendar-card__day']); if ($isCurrentMonth && $day === $today) $classes->push('is-today'); if (in_array($day, $events)) $classes->push('is-event'); @endphp
{{ $day }}
@endfor