mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 15:19:56 +08:00
34 lines
939 B
PHP
34 lines
939 B
PHP
<?php
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Api\Serializers;
|
|
|
|
class CurrentUserSerializer extends UserSerializer
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getDefaultAttributes($user)
|
|
{
|
|
$attributes = parent::getDefaultAttributes($user);
|
|
|
|
if ($user->id == $this->actor->id) {
|
|
$attributes += [
|
|
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
|
'unreadNotificationsCount' => $user->getUnreadNotificationsCount(),
|
|
'newNotificationsCount' => $user->getNewNotificationsCount(),
|
|
'preferences' => $user->preferences
|
|
];
|
|
}
|
|
|
|
return $attributes;
|
|
}
|
|
}
|