This gist contains a Laravel controller that processes an uploaded attendance sheet image (JPEG/PNG/etc.) and converts it into a clean, normalized JSON format using an AI model.
- Validates uploaded attendance image (JPEG, PNG, JPG, GIF, SVG).
- Converts image to Base64 and sends to Groq API for processing.
- Applies a strict parsing & normalization prompt to ensure consistent output.
- Handles:
- Date normalization (
DD/MM/YYYYformat). - Time formatting & zero-padding (
HH:mm). - Range values (e.g.,
"9 to 18"→in: 09:00, out: 18:00). - AM/PM → 24-hour conversion.
- Missing or empty values (set to
null). - Out-time adjustment (e.g.,
9:32→21:32).
- Date normalization (
- Returns JSON only, grouped by
device_id.
{
"1234": [
{ "date": "01/09/2025", "in": "08:00", "out": "21:15" },
{ "date": "02/09/2025", "in": "07:55", "out": null }
]
}