78 lines
1.9 KiB
PHP
78 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Casts\VectorCast;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/** @property array<int, float>|null $embedding */
|
|
class Ticket extends Model
|
|
{
|
|
protected $fillable = [
|
|
'message',
|
|
'normalized_message',
|
|
'redaction_report',
|
|
'embedding',
|
|
'embedding_provider_instance_id',
|
|
'embedding_model',
|
|
'embedded_at',
|
|
'status',
|
|
'best_article_id',
|
|
'confidence',
|
|
'explanation',
|
|
'support_reply',
|
|
'needs_article_draft',
|
|
'draft_article_id',
|
|
'result_payload',
|
|
'api_credentials',
|
|
'error_message',
|
|
'processed_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'embedding' => VectorCast::class,
|
|
'redaction_report' => 'array',
|
|
'result_payload' => 'array',
|
|
'api_credentials' => 'encrypted:array',
|
|
'needs_article_draft' => 'boolean',
|
|
'embedded_at' => 'datetime',
|
|
'processed_at' => 'datetime',
|
|
];
|
|
|
|
public function decisions(): HasMany
|
|
{
|
|
return $this->hasMany(AIDecision::class);
|
|
}
|
|
|
|
public function feedback(): HasMany
|
|
{
|
|
return $this->hasMany(Feedback::class);
|
|
}
|
|
|
|
public function logs(): HasMany
|
|
{
|
|
return $this->hasMany(TicketProcessingLog::class)
|
|
->orderByDesc('created_at')
|
|
->orderByDesc('id');
|
|
}
|
|
|
|
public function toolCalls(): HasMany
|
|
{
|
|
return $this->hasMany(TicketToolCall::class)
|
|
->orderByDesc('created_at')
|
|
->orderByDesc('id');
|
|
}
|
|
|
|
public function bestArticle(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Article::class, 'best_article_id');
|
|
}
|
|
|
|
public function draftArticle(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Article::class, 'draft_article_id');
|
|
}
|
|
}
|