<?php

namespace App\Models;

use App\Enums\AttendanceStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SessionAttendance extends Model
{
    use HasFactory;

    protected $fillable = [
        'coach_session_id',
        'member_id',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'coach_session_id' => 'integer',
            'member_id'        => 'integer',
            'status'           => 'integer',
        ];
    }

    // ── Relationships ──

    public function coachSession()
    {
        return $this->belongsTo(CoachSession::class);
    }

    public function member()
    {
        return $this->belongsTo(Member::class);
    }

    // ── Helpers ──

    public function statusLabel(): string
    {
        return AttendanceStatusEnum::label($this->status);
    }

    public function statusColor(): string
    {
        return AttendanceStatusEnum::color($this->status);
    }
}
