<?php

namespace App\Models;

use App\Models\Concerns\BelongsToBranch;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TeacherAttendance extends Model
{
    use BelongsToBranch;

    protected $fillable = [
        'branch_id', 'user_id', 'date', 'status',
        'check_in', 'check_out', 'remarks', 'marked_by',
    ];

    protected function casts(): array
    {
        return ['date' => 'date'];
    }

    public const STATUSES = ['present', 'absent', 'leave', 'late'];

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

    public static function statusColor(string $status): string
    {
        return [
            'present' => 'success', 'absent' => 'danger', 'leave' => 'info', 'late' => 'warning',
        ][$status] ?? 'secondary';
    }
}
