(int) $notification->id, 'contentType' => $notification->type, 'content' => $notification->data, 'time' => $notification->time->toRFC3339String(), 'isRead' => (bool) $notification->is_read, 'unreadCount' => $notification->unread_count ]; } /** * @return callable */ public function user() { return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer'); } /** * @return callable */ public function sender() { return $this->hasOne('Flarum\Api\Serializers\UserBasicSerializer'); } /** * @return callable */ public function subject() { return $this->hasOne(function ($notification) { return static::$subjectSerializers[$notification->type]; }); } /** * @param $type * @param $serializer */ public static function setSubjectSerializer($type, $serializer) { static::$subjectSerializers[$type] = $serializer; } }