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'); });