CasperSecurity
require('./bootstrap');
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'YBTKey',
wsHost: window.location.hostname,
wsPort: 6001,
forceTLS: false,
disableStats: true,
});
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
window.Echo.private(`App.Models.User.${userId}`)
.notification((notification) => {
const notificationCount = parseInt(document.querySelector('.badge').textContent, 10) || 0;
document.querySelector('.badge').textContent = notificationCount + 1;
// Add the new notification to the dropdown
const dropdown = document.querySelector('.dropdown-menu');
const newNotification = document.createElement('li');
newNotification.innerHTML = `<a class="dropdown-item" href="#">${notification.message}</a>`;
dropdown.prepend(newNotification);
});