<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class WorkReport extends Model
{
    protected $fillable = [
        'attendance_id', 'user_id', 'raw_summary', 'total_tasks',
        'is_submitted', 'submitted_at', 'admin_notes',
        'approval_status', 'approved_by', 'approved_at'
    ];

    protected $casts = [
        'is_submitted' => 'boolean',
        'submitted_at' => 'datetime',
        'approved_at' => 'datetime',
    ];

    public function attendance()
    {
        return $this->belongsTo(Attendance::class);
    }

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

    public function approvedBy()
    {
        return $this->belongsTo(User::class, 'approved_by');
    }

    public function tasks()
    {
        return $this->hasMany(Task::class);
    }
}
