<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class AttendanceSession extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'attendance_date',
        'start_time',
        'stop_time',
        'start_video_path',
        'stop_video_path',
        'start_video_seconds',
        'stop_video_seconds',
        'total_work_minutes',
        'lunch_minutes',
        'net_work_minutes',
        'status',
        'is_absent',
        'manual_present',
    ];

    protected function casts(): array
    {
        return [
            'attendance_date' => 'date',
            'start_time' => 'datetime',
            'stop_time' => 'datetime',
            'is_absent' => 'boolean',
            'manual_present' => 'boolean',
        ];
    }

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

    public function lunchBreaks(): HasMany
    {
        return $this->hasMany(LunchBreak::class);
    }

    public function workLogs(): HasMany
    {
        return $this->hasMany(DailyWorkLog::class);
    }
}
