chatbot nuevo

This commit is contained in:
Lizandro Guarnizo
2026-04-30 21:32:32 -05:00
parent 88a42ec629
commit f61e8005fc
24 changed files with 1724 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ChatContact extends Model
{
protected $table = 'chat_contacts';
protected $fillable = ['canal', 'canal_id', 'nombre', 'telefono', 'metadata'];
protected $casts = ['metadata' => 'array'];
public function conversations(): HasMany
{
return $this->hasMany(ChatConversation::class, 'contact_id');
}
public function activeConversation(): ?ChatConversation
{
return $this->conversations()
->whereIn('estado', ['bot', 'agente'])
->latest()
->first();
}
}