From 60ddc4b9df0644e6dd5b855ac7831065c8c2fb2b Mon Sep 17 00:00:00 2001 From: Lizandro Date: Wed, 29 Jul 2026 21:13:31 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20p=C3=A1gina=20de=20comprobantes,=20b?= =?UTF-8?q?=C3=BAsqueda=20por=20email=20en=20conversaciones,=20quitar=20me?= =?UTF-8?q?n=C3=BAs=20del=20bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Nueva página /chat/comprobantes: tabla paginada de solicitudes_recarga con búsqueda por email/nombre, filtros por estado y canal, botón "Ver chat" - ShowConversaciones: búsqueda también por email del usuario autenticado - ShowConversaciones: soporta ?conv=ID para abrir conversación desde comprobantes - Nav: reemplaza "Menús del Bot" (no funcional) por "Comprobantes" - SolicitudRecarga: relación user() agregada - ChatController: método comprobantes() agregado Co-Authored-By: Claude Sonnet 4.6 --- app/Http/Controllers/ChatController.php | 5 + app/Http/Livewire/Chat/ShowComprobantes.php | 53 ++++++++++ app/Http/Livewire/Chat/ShowConversaciones.php | 12 ++- app/Models/SolicitudRecarga.php | 6 ++ resources/views/chat/comprobantes.blade.php | 6 ++ resources/views/layouts/navigation.blade.php | 6 +- .../livewire/chat/show-comprobantes.blade.php | 99 +++++++++++++++++++ routes/web.php | 2 +- 8 files changed, 184 insertions(+), 5 deletions(-) mode change 100644 => 100755 app/Http/Controllers/ChatController.php create mode 100644 app/Http/Livewire/Chat/ShowComprobantes.php mode change 100644 => 100755 app/Http/Livewire/Chat/ShowConversaciones.php create mode 100644 resources/views/chat/comprobantes.blade.php mode change 100644 => 100755 resources/views/layouts/navigation.blade.php create mode 100644 resources/views/livewire/chat/show-comprobantes.blade.php mode change 100644 => 100755 routes/web.php diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php old mode 100644 new mode 100755 index 862df83..e73c86d --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -14,6 +14,11 @@ class ChatController extends Controller return view('chat.conversaciones'); } + public function comprobantes() + { + return view('chat.comprobantes'); + } + public function menus() { return view('chat.menus'); diff --git a/app/Http/Livewire/Chat/ShowComprobantes.php b/app/Http/Livewire/Chat/ShowComprobantes.php new file mode 100644 index 0000000..6a5e0c1 --- /dev/null +++ b/app/Http/Livewire/Chat/ShowComprobantes.php @@ -0,0 +1,53 @@ + ['except' => ''], + 'filtroEstado' => ['except' => ''], + 'filtroCanal' => ['except' => ''], + ]; + + public function updatingBusqueda(): void { $this->resetPage(); } + public function updatingFiltroEstado(): void { $this->resetPage(); } + public function updatingFiltroCanal(): void { $this->resetPage(); } + + public function verChat(int $userId): void + { + $conv = ChatConversation::whereHas('contact', fn($q) => $q->where('user_id', $userId)) + ->orderByDesc('ultimo_mensaje_at') + ->first(); + + if ($conv) { + $this->redirect(route('chat.conversaciones') . '?conv=' . $conv->id); + } + } + + public function render() + { + $solicitudes = SolicitudRecarga::with('user') + ->when($this->filtroEstado, fn($q) => $q->where('estado', $this->filtroEstado)) + ->when($this->filtroCanal, fn($q) => $q->where('canal', $this->filtroCanal)) + ->when($this->busqueda, fn($q) => $q->whereHas('user', fn($s) => + $s->where('email', 'like', "%{$this->busqueda}%") + ->orWhere('name', 'like', "%{$this->busqueda}%") + )) + ->orderByDesc('id') + ->paginate(25); + + return view('livewire.chat.show-comprobantes', compact('solicitudes')); + } +} diff --git a/app/Http/Livewire/Chat/ShowConversaciones.php b/app/Http/Livewire/Chat/ShowConversaciones.php old mode 100644 new mode 100755 index d82a948..2d4ae78 --- a/app/Http/Livewire/Chat/ShowConversaciones.php +++ b/app/Http/Livewire/Chat/ShowConversaciones.php @@ -15,6 +15,15 @@ class ShowConversaciones extends Component public string $replyText = ''; public array $mensajes = []; + protected $queryString = ['convSelecId' => ['except' => null, 'as' => 'conv']]; + + public function mount(): void + { + if ($this->convSelecId) { + $this->cargarMensajes(); + } + } + public function selectConv(int $convId): void { $this->convSelecId = $convId; @@ -124,7 +133,8 @@ class ShowConversaciones extends Component $q->whereHas('contact', function ($s) { $s->where('nombre', 'like', "%{$this->busqueda}%") ->orWhere('telefono', 'like', "%{$this->busqueda}%") - ->orWhere('canal_id', 'like', "%{$this->busqueda}%"); + ->orWhere('canal_id', 'like', "%{$this->busqueda}%") + ->orWhereHas('user', fn($u) => $u->where('email', 'like', "%{$this->busqueda}%")); }); }) ->orderByDesc('ultimo_mensaje_at') diff --git a/app/Models/SolicitudRecarga.php b/app/Models/SolicitudRecarga.php index cce2fa2..93553a1 100644 --- a/app/Models/SolicitudRecarga.php +++ b/app/Models/SolicitudRecarga.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Models\User; use Illuminate\Database\Eloquent\Model; class SolicitudRecarga extends Model @@ -55,4 +56,9 @@ class SolicitudRecarga extends Model { $this->update(['estado' => 'confirmada']); } + + public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(User::class); + } } diff --git a/resources/views/chat/comprobantes.blade.php b/resources/views/chat/comprobantes.blade.php new file mode 100644 index 0000000..5e73695 --- /dev/null +++ b/resources/views/chat/comprobantes.blade.php @@ -0,0 +1,6 @@ + + +

Comprobantes de Recarga

+
+ +
diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php old mode 100644 new mode 100755 index fa3da56..1b523ec --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -276,9 +276,9 @@ Conversaciones - - - Menús del Bot + + + Comprobantes diff --git a/resources/views/livewire/chat/show-comprobantes.blade.php b/resources/views/livewire/chat/show-comprobantes.blade.php new file mode 100644 index 0000000..ca0a35b --- /dev/null +++ b/resources/views/livewire/chat/show-comprobantes.blade.php @@ -0,0 +1,99 @@ +
+ + {{-- Filtros --}} +
+ + + + + +
+ + {{-- Tabla --}} +
+ + + + + + + + + + + + + + + @forelse($solicitudes as $s) + + + + + + + + + + + @empty + + + + @endforelse + +
#FechaUsuarioCanalTitularMontoEstadoChat
{{ $s->id }} + {{ $s->created_at ? $s->created_at->format('d/m/y H:i') : '—' }} + + @if($s->user) +

{{ $s->user->name }}

+

{{ $s->user->email }}

+ @else + Usuario eliminado + @endif +
+ @if($s->canal === 'telegram') + ✈️ Telegram + @else + 🌐 Web + @endif + {{ $s->nombre_remitente ?? '—' }} + ${{ number_format($s->monto) }} + + @if($s->estado === 'confirmada') + ✅ Confirmada + @elseif($s->estado === 'pendiente') + 🟡 Pendiente + @else + ⛔ Expirada + @endif + + @if($s->user_id) + + @endif +
No hay registros
+ + @if($solicitudes->hasPages()) +
+ {{ $solicitudes->links() }} +
+ @endif +
+ +
diff --git a/routes/web.php b/routes/web.php old mode 100644 new mode 100755 index ef45a46..90749c8 --- a/routes/web.php +++ b/routes/web.php @@ -97,7 +97,7 @@ Route::middleware(["auth", "solo_usuario_administrador"])->group(function () { // Módulo Chat (web + Telegram) Route::prefix('chat')->name('chat.')->group(function () { Route::get('/conversaciones', [ChatController::class, 'conversaciones'])->name('conversaciones'); - Route::get('/menus', [ChatController::class, 'menus'])->name('menus'); + Route::get('/comprobantes', [ChatController::class, 'comprobantes'])->name('comprobantes'); Route::get('/configuracion', [ChatController::class, 'configuracion'])->name('configuracion'); Route::get('/ia-logs', [ChatController::class, 'iaLogs'])->name('ia-logs'); });