<?php

namespace App\Models;

use App\Modules\Users\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TextAnalysisRequest extends Model
{
    public const STATUS_PENDING = 'pending';

    public const STATUS_COMPLETED = 'completed';

    public const STATUS_FAILED = 'failed';

    protected $fillable = [
        'user_id',
        'original_text',
        'analysis_result',
        'humanized_text',
        'ai_probability_score',
        'readability_score',
        'tone',
        'status',
        'tokens_used',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'ai_probability_score' => 'integer',
            'readability_score' => 'integer',
            'tokens_used' => 'integer',
        ];
    }

    /** @return BelongsTo<User, TextAnalysisRequest> */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
