API for marking all as read

This commit is contained in:
Toby Zerner 2015-02-10 17:48:58 +10:30
parent eec50f687c
commit 8e6011e8d0
6 changed files with 10 additions and 2 deletions

View File

@ -29,6 +29,7 @@ class UserSerializer extends UserBasicSerializer
$attributes += [
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
'discussionsCount' => (int) $user->discussions_count,
'postsCount' => (int) $user->posts_count,
'canEdit' => $user->permission('edit'),

View File

@ -12,6 +12,8 @@ class EditUserCommand
public $password;
public $readTime;
public function __construct($userId, $user)
{
$this->userId = $userId;

View File

@ -36,6 +36,10 @@ class EditUserCommandHandler implements CommandHandler
$userToEdit->password = $command->password;
}
if (! empty($command->readTime)) {
$userToEdit->read_time = time();
}
Event::fire('Flarum.Core.Users.Commands.EditUser.UserWillBeSaved', [$userToEdit, $command]);
$this->userRepo->save($userToEdit);

View File

@ -93,7 +93,7 @@ class User extends Entity implements UserInterface, RemindableInterface
public function getDates()
{
return ['join_time', 'last_seen_time'];
return ['join_time', 'last_seen_time', 'read_time'];
}
public function getAvatarUrlAttribute()

View File

@ -22,6 +22,7 @@ class CreateUsersTable extends Migration {
$table->dateTime('join_time');
$table->string('time_zone');
$table->dateTime('last_seen_time')->nullable();
$table->dateTime('read_time')->nullable();
$table->integer('discussions_count')->unsigned()->default(0);
$table->integer('posts_count')->unsigned()->default(0);
});

View File

@ -4,4 +4,4 @@ Route::get('/', function()
{
return View::make('flarum.web::index')
->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum'));
});
});