<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class MembershipRenewal extends Model
{
    protected $fillable = [
        'member_id',
        'certificate_id',
        'renewal_type',
        'renewed_at',
        'previous_end_date',
        'new_end_date',
        'processed_by',
    ];

    protected $casts = [
        'renewed_at' => 'datetime',
        'previous_end_date' => 'date',
        'new_end_date' => 'date',
    ];

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

    public function certificate(): BelongsTo
    {
        return $this->belongsTo(MembershipCertificate::class, 'certificate_id');
    }

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