chatbot nuevo
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user