mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
API for marking all as read
This commit is contained in:
parent
eec50f687c
commit
8e6011e8d0
|
@ -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'),
|
||||
|
|
|
@ -12,6 +12,8 @@ class EditUserCommand
|
|||
|
||||
public $password;
|
||||
|
||||
public $readTime;
|
||||
|
||||
public function __construct($userId, $user)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -4,4 +4,4 @@ Route::get('/', function()
|
|||
{
|
||||
return View::make('flarum.web::index')
|
||||
->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum'));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user