Skip to content

NotificationUser Model ​

DB Table Name{wp_db_prefix}fbs_notification_users
SchemaCheck Schema
Source Filefluent-boards/app/Models/NotificationUser.php
Name SpaceFluentBoards\App\Models
ClassFluentBoards\App\Models\NotificationUser

Links a Notification to a recipient and stores whether they read it. On create, the model sets created_at / updated_at with current_time('mysql').

Attributes ​

AttributeData TypeComment
idINT UNSIGNEDPrimary key
notification_idINT UNSIGNED NULLNotification ID
user_idBIGINT UNSIGNEDRecipient user ID
marked_read_atTIMESTAMP NULLRead time. NULL means unread
created_atTIMESTAMP NULL
updated_atTIMESTAMP NULL

Usage ​

Please check Model Basic for common methods.

php
use FluentBoards\App\Models\NotificationUser;

// Mark all notifications of the current user as read
NotificationUser::where('user_id', get_current_user_id())
    ->whereNull('marked_read_at')
    ->update(['marked_read_at' => current_time('mysql')]);

// Unread count
$unread = NotificationUser::where('user_id', get_current_user_id())
    ->whereNull('marked_read_at')
    ->count();

Relations ​

notification ​

  • Returns FluentBoards\App\Models\Notification
php
$row = NotificationUser::with('notification')->find(1);
$text = $row->notification->description;