39 lines
878 B
PHP
Executable File
39 lines
878 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Notificacion;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Livewire\Component;
|
|
|
|
class Bell extends Component
|
|
{
|
|
public $numNoti = 0;
|
|
public $menuNotificaciones = false;
|
|
|
|
public function render()
|
|
{
|
|
$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]);
|
|
}
|
|
}
|
|
}
|