<?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 ProgressReport extends Model
{
    use HasFactory;

    protected $fillable = [
        'project_id',
        'reported_by_id',
        'summary',
        'completion_percentage',
        'percentage_complete',
        'status',
        'report_kind',
        'notes',
        'description',
        'report_payload',
        'report_date',
    ];

    protected $casts = [
        'completion_percentage' => 'integer',
        'report_payload' => 'array',
        'report_date' => 'date',
    ];

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

    public function reporter(): BelongsTo
    {
        return $this->belongsTo(User::class, 'reported_by_id');
    }

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