where(function ($query) { $query->where('todos', true) ->orWhere('destinatario_id', Auth::user()->id); })->orderBy('created_at', 'desc') ->get(); $this->numNoti = count($consulta); return view('livewire.bell', [ 'consulta' => $consulta, ]); } public function deleteNotificacion($id) { $notificacion = Notificacion::find($id); if ($notificacion) { $notificacion->update(['estado' => false]); } } public function reclamarPremio($id) { if ($this->reclamandoPremio) { return; } $this->reclamandoPremio = true; $notificacion = Notificacion::find($id); if (!$notificacion || $notificacion->estado == 0) { $this->reclamandoPremio = false; $this->alert('error', 'No se pudo reclamar el premio', [ 'position' => 'top' ]); return; } $consulta_saldo = Saldo::where('usuario_id', Auth::user()->id)->first(); if ($consulta_saldo) { $consulta_saldo->update([ 'valor' => $consulta_saldo->valor + $notificacion->premio ]); if ($notificacion) { $notificacion->update(['estado' => false]); } } Log_general::create([ 'user_id' => Auth::user()->id, 'detalle' => 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha reclamado el premio de $' . $notificacion->premio ]); $this->reclamandoPremio = false; $this->alert('success', 'Haz reclamado el premio correctamente', [ 'position' => 'top' ]); } }