<?php

namespace App\Models;

use App\Enums\ApprovalStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;

class CooperationProposal extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'status' => ApprovalStatus::class,
            'proposed_start_date' => 'date',
            'proposed_end_date' => 'date',
        ];
    }

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

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

    public function rejectionReasons(): MorphMany
    {
        return $this->morphMany(RejectionReason::class, 'rejectable');
    }
}
