- 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 <noreply@anthropic.com>
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Chat;
|
|
|
|
use App\Models\ChatConversation;
|
|
use App\Models\SolicitudRecarga;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class ShowComprobantes extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public string $busqueda = '';
|
|
public string $filtroEstado = '';
|
|
public string $filtroCanal = '';
|
|
|
|
protected $queryString = [
|
|
'busqueda' => ['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'));
|
|
}
|
|
}
|