1
0
mirror of https://github.com/flarum/core.git synced 2025-10-19 02:36:08 +02:00

fixed more attributes to match beta 8

This commit is contained in:
Daniel Klabbers
2018-05-14 13:49:52 +02:00
parent a9501ceae0
commit 3e3e1cbde5
22 changed files with 65 additions and 45 deletions

View File

@@ -57,7 +57,7 @@ class AuthToken extends AbstractModel
$token->token = str_random(40);
$token->payload = $payload;
$token->created_at = time();
$token->created_at = Carbon::now();
return $token;
}

View File

@@ -11,6 +11,7 @@
namespace Flarum\User;
use Carbon\Carbon;
use DateTime;
use Flarum\Database\AbstractModel;
use Flarum\User\Exception\InvalidConfirmationTokenException;
@@ -55,7 +56,7 @@ class EmailToken extends AbstractModel
$token->token = str_random(40);
$token->user_id = $userId;
$token->email = $email;
$token->created_at = time();
$token->created_at = Carbon::now();
return $token;
}
@@ -80,9 +81,10 @@ class EmailToken extends AbstractModel
*/
public function scopeValidOrFail($query, $id)
{
/** @var EmailToken $token */
$token = $query->find($id);
if (! $token || $token->created_at < new DateTime('-1 day')) {
if (! $token || $token->created_at->diffInDays() >= 1) {
throw new InvalidConfirmationTokenException;
}

View File

@@ -11,6 +11,7 @@
namespace Flarum\User;
use Carbon\Carbon;
use Flarum\Database\AbstractModel;
/**
@@ -54,7 +55,7 @@ class PasswordToken extends AbstractModel
$token->token = str_random(40);
$token->user_id = $userId;
$token->created_at = time();
$token->created_at = Carbon::now();
return $token;
}

View File

@@ -11,6 +11,7 @@
namespace Flarum\User;
use Carbon\Carbon;
use DomainException;
use Flarum\Database\AbstractModel;
use Flarum\Database\ScopeVisibilityTrait;
@@ -166,7 +167,7 @@ class User extends AbstractModel
$user->username = $username;
$user->email = $email;
$user->password = $password;
$user->joined_at = time();
$user->joined_at = Carbon::now();
$user->raise(new Registered($user));
@@ -270,7 +271,7 @@ class User extends AbstractModel
*/
public function markAllAsRead()
{
$this->marked_all_as_read_at = time();
$this->marked_all_as_read_at = Carbon::now();
return $this;
}
@@ -282,7 +283,7 @@ class User extends AbstractModel
*/
public function markNotificationsAsRead()
{
$this->read_notifications_at = time();
$this->read_notifications_at = Carbon::now();
return $this;
}
@@ -469,7 +470,7 @@ class User extends AbstractModel
public function getNewNotificationsCount()
{
return $this->getUnreadNotifications()->filter(function ($notification) {
return $notification->time > $this->read_notifications_at ?: 0;
return $notification->created_at > $this->read_notifications_at ?: 0;
})->count();
}
@@ -568,7 +569,7 @@ class User extends AbstractModel
*/
public function updateLastSeen()
{
$this->last_seen_at = time();
$this->last_seen_at = Carbon::now();
return $this;
}