From 42604a658ce5392dd7622624ea6a71608fc32843 Mon Sep 17 00:00:00 2001 From: Felipe Date: Mon, 23 Oct 2023 11:55:43 -0500 Subject: [PATCH] notificaciones pulida --- app/Http/Livewire/Bell.php | 28 +++++++++++++++-- resources/views/livewire/bell.blade.php | 42 +++++++++++++++++-------- 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/app/Http/Livewire/Bell.php b/app/Http/Livewire/Bell.php index 3c54134..5137e30 100644 --- a/app/Http/Livewire/Bell.php +++ b/app/Http/Livewire/Bell.php @@ -2,15 +2,37 @@ namespace App\Http\Livewire; +use App\Models\Notificacion; +use Illuminate\Support\Facades\Auth; use Livewire\Component; class Bell extends Component { - public $noti = 8; - public $notificaciones = false; + public $numNoti = 0; + public $menuNotificaciones = false; public function render() { - return view('livewire.bell'); + $consulta = Notificacion::where('estado', true) + ->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]); + } } } diff --git a/resources/views/livewire/bell.blade.php b/resources/views/livewire/bell.blade.php index 0febcf5..682273e 100644 --- a/resources/views/livewire/bell.blade.php +++ b/resources/views/livewire/bell.blade.php @@ -1,20 +1,36 @@ -
+
- - {{ $noti > 9 ? '9+' : $noti }} - + wire:click="$refresh" @click="menuNotificaciones=!menuNotificaciones"> + @if ($numNoti != 0) + + {{ $numNoti > 9 ? '9+' : $numNoti }} + + @endif - +
-
-
- hola hola - hola -
+
+
    + @foreach ($consulta as $item) +
  • +

    + {{ $item->titulo }} +

    +

    + {{ $item->descripcion }} +

    + @if (!$item->todos) + + x + + + x + + @endif +
  • + @endforeach +