<?php

namespace App\Models;

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

class CollectionFollowUp extends Model
{
    public const ACTION_TYPES = [
        'called', 'sms', 'visit', 'promise_to_pay', 'guarantor_contacted', 'demand_notice', 'other',
    ];

    protected $fillable = [
        'loan_id', 'customer_id', 'branch_id', 'action_type', 'action_at', 'notes', 'promise_date', 'employee_id',
    ];

    protected function casts(): array
    {
        return ['action_at' => 'datetime', 'promise_date' => 'date'];
    }

    public function loan(): BelongsTo { return $this->belongsTo(Loan::class); }
    public function customer(): BelongsTo { return $this->belongsTo(Customer::class); }
    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function employee(): BelongsTo { return $this->belongsTo(User::class, 'employee_id'); }
}
