PHP code example of marko / notification-database
1. Go to this page and download the library: Download marko/notification-database library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marko / notification-database example snippets
use Marko\Notification\Database\Repository\NotificationRepositoryInterface;
public function __construct(
private NotificationRepositoryInterface $notificationRepository,
) {}
// Fetch all notifications for a user
$notifications = $this->notificationRepository->forNotifiable($user);
// Count unread
$count = $this->notificationRepository->unreadCount($user);
// Mark all as read
$this->notificationRepository->markAllAsRead($user);