<?php

namespace App\Models;

use App\Enums\OverdrachtsStatus;
use App\Enums\OverdrachtsType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Overdrachtsplan extends Model
{
    protected $table = 'overdrachtsplannen';

    protected $fillable = [
        'project_id',
        'type',
        'status',
        'eigenaar_rnd_id',
        'eigenaar_ontvanger_id',
    ];

    protected function casts(): array
    {
        return [
            'type'   => OverdrachtsType::class,
            'status' => OverdrachtsStatus::class,
        ];
    }

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

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

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

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

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