public function getAllUnread(User $user = null)
    {
        // If there's no passed user, get the current logged in user
        $user = $user ?? Craft::$app->getUser();

        if ($user) {
            $notifications = NotificationsRecord::find()->where(['notifiable' => $user->id, 'read_at' => null])->all();
            return $this->formatNotificationData($notifications)->toArray();
        }

        // No notifications when we don't have a passed in or logged in user
        return [];
    }
public function getAllUnread(User $user = null)
    {
        // If there's no passed user, get the current logged in user
        $user = $user ?? Craft::$app->getUser();

        if ($user) {
            $notifications = NotificationsRecord::find()->where(['notifiable' => $user->id, 'read_at' => null])->all();
            return $this->formatNotificationData($notifications)->toArray();
        }

        // No notifications when we don't have a passed in or logged in user
        return [];
    }
public function getAllUnread ( User $ user = null ) { // If there's no passed user, get the current logged in user $ user = $ user ?? Craft :: $ app -> getUser ( ) ; if ( $ user ) { $ notifications = NotificationsRecord :: find ( ) -> where ( [ 'notifiable' => $ user -> id , 'read_at' => null ] ) -> all ( ) ; return $ this -> formatNotificationData ( $ notifications ) -> toArray ( ) ; } // No notifications when we don't have a passed in or logged in user return [ ] ; }
Get all unread notifications for a certain User

@param User $user

@return array
Get all unread notifications for a certain User