<?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\SoftDeletes;

class IdleLog extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'user_id', 'time_log_id', 'idle_started_at', 'idle_ended_at', 'idle_seconds', 'reason',
    ];

    protected function casts(): array
    {
        return [
            'idle_started_at' => 'datetime',
            'idle_ended_at' => 'datetime',
        ];
    }

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