/** * {@inheritDoc} * @see \DMA\Friends\Classes\Notifications\Channels\Channel::send() */ public function send(NotificationMessage $message) { $notification = new Notification(); $notification->user = $message->getTo(); $notification->subject = $message->getSubject(); $notification->message = (string) $message->getContent(); if (!empty($notification->message)) { // Attach object to notification if it exists in the message if (!is_null($attachObject = $message->getAttachObject())) { if (is_object($attachObject)) { $notification->object_id = $attachObject->id; $notification->object_type = get_class($attachObject); } } return $notification->save(); } }
public function onMarkRead() { if (($id = post('id')) != '') { if ($notification = Notification::find($id)) { $notification->markAsRead(); } } $count = $this->getUnreadCount(); $count = $count > 0 ? $count : ''; $this->prepareVars(); return ['#notification-counter .badge' => $count]; }