<?php

namespace App\Services;
// AttendanceService.php
use App\Models\Attendance;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

class AttendanceService
{
    public function getUniqueEmployeeCountPerWeek($startDate, $endDate)
    {
        return Attendance::whereBetween('date', [$startDate, $endDate])
            ->groupBy(DB::raw('DATE(date)')) 
            ->selectRaw('count(distinct employee_id) as employee_count, DATE(date) as week_start')
            ->pluck('employee_count', 'week_start');
    }
}