notificaciones pulida

This commit is contained in:
Felipe
2023-10-23 11:55:43 -05:00
parent 1d3fac965d
commit 42604a658c
2 changed files with 54 additions and 16 deletions
+25 -3
View File
@@ -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]);
}
}
}