<?php

namespace App\Models;

use App\Enums\FaseStatus;
use App\Enums\FaseType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Fase extends Model
{
    protected $table = 'fases';
    protected $fillable = [
        'project_id',
        'type',
        'status',
        'startdatum',
        'einddatum',
        'opmerkingen',
    ];

    protected function casts(): array
    {
        return [
            'type'       => FaseType::class,
            'status'     => FaseStatus::class,
            'startdatum' => 'date',
            'einddatum'  => 'date',
        ];
    }

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

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

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