<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Attendance extends Model
{
    protected $guarded = ['id'];

    protected $casts = ['date' => 'date'];

    // Attendance codes and their meaning (used for the legend + colouring).
    public const CODES = [
        'P'  => 'Present',
        'A'  => 'Absent',
        'R'  => 'Rest day',
        'MC' => 'Medical leave',
        'AL' => 'Annual leave',
        'UL' => 'Unpaid leave',
        'PH' => 'Public holiday',
        'HD' => 'Half day',
    ];

    public function staff(): BelongsTo
    {
        return $this->belongsTo(Staff::class);
    }

    public function site(): BelongsTo
    {
        return $this->belongsTo(Site::class);
    }
}
