<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class KycActivityLog extends Model
{
    use HasFactory;

    protected $fillable = [
        'seller_id',
        'kyc_document_id',
        'action',
        'actor_type',
        'actor_id',
        'notes',
    ];

    public function seller()
    {
        return $this->belongsTo(Seller::class);
    }

    public function document()
    {
        return $this->belongsTo(KycDocument::class, 'kyc_document_id');
    }

    public function actor()
    {
        return $this->belongsTo(User::class, 'actor_id');
    }

    /**
     * Get action icon for timeline display
     */
    public function getActionIconAttribute(): string
    {
        return match($this->action) {
            'submitted' => 'bi-cloud-upload text-primary',
            'approved' => 'bi-check-circle text-success',
            'rejected' => 'bi-x-circle text-danger',
            'resubmitted' => 'bi-arrow-repeat text-warning',
            default => 'bi-circle text-secondary'
        };
    }

    /**
     * Get action label for timeline display
     */
    public function getActionLabelAttribute(): string
    {
        return match($this->action) {
            'submitted' => 'Document Submitted',
            'approved' => 'Document Approved',
            'rejected' => 'Document Rejected',
            'resubmitted' => 'Document Resubmitted',
            default => ucfirst($this->action)
        };
    }
}
