<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class OcrJob extends Model
{
    use BelongsToTenant;

    public const STATUSES = [
        'pending' => 'În așteptare',
        'processing' => 'Procesare',
        'done' => 'Finalizat',
        'failed' => 'Eșuat',
    ];

    protected $fillable = [
        'company_id', 'supplier_id', 'source_type', 'file_path', 'status',
        'result', 'error_message', 'ai_provider', 'tokens_used',
        'purchase_id', 'processed_at',
    ];

    protected $casts = [
        'result' => 'array',
        'processed_at' => 'datetime',
        'tokens_used' => 'integer',
    ];

    public function supplier(): BelongsTo { return $this->belongsTo(Supplier::class); }
    public function purchase(): BelongsTo { return $this->belongsTo(Purchase::class); }
}
