<?php

namespace App\Models;

use App\Enums\Prioriteit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Risico extends Model
{
    protected $table = 'risicos';

    protected $fillable = [
        'project_id',
        'beschrijving',
        'impact',
        'kans',
        'mitigatie',
        'eigenaar_id',
    ];

    protected function casts(): array
    {
        return [
            'impact' => Prioriteit::class,
            'kans'   => Prioriteit::class,
        ];
    }

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

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