From 8937050aed2cd3833de1cb9375e7adfa9d417239 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 22 Sep 2015 16:54:32 +0930 Subject: [PATCH] Rename column for consistency --- CHANGELOG.md | 1 + ...2_030432_rename_notification_read_time.php | 33 +++++++++++++++++++ src/Core/Users/User.php | 6 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 migrations/2015_09_22_030432_rename_notification_read_time.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f3592bb65..39fd9275b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Migrations must be namespaced under `Flarum\Migrations\{Core|ExtensionName}`. ([#422](https://github.com/flarum/core/issues/422)) - More compact post layout, with all controls grouped over to the right. +- Rename `notification_read_time` column in discussions table to `notifications_read_time`. ### Fixed - Output forum description in meta description tag. ([#506](https://github.com/flarum/core/issues/506)) diff --git a/migrations/2015_09_22_030432_rename_notification_read_time.php b/migrations/2015_09_22_030432_rename_notification_read_time.php new file mode 100644 index 000000000..e10511463 --- /dev/null +++ b/migrations/2015_09_22_030432_rename_notification_read_time.php @@ -0,0 +1,33 @@ +schema->table('users', function (Blueprint $table) { + $table->renameColumn('notification_read_time', 'notifications_read_time'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $this->schema->table('users', function (Blueprint $table) { + $table->renameColumn('notifications_read_time', 'notification_read_time'); + }); + } +} diff --git a/src/Core/Users/User.php b/src/Core/Users/User.php index 29541f0b7..b2b20f3f0 100755 --- a/src/Core/Users/User.php +++ b/src/Core/Users/User.php @@ -71,7 +71,7 @@ class User extends Model 'join_time', 'last_seen_time', 'read_time', - 'notification_read_time' + 'notifications_read_time' ]; /** @@ -295,7 +295,7 @@ class User extends Model */ public function markNotificationsAsRead() { - $this->notification_read_time = time(); + $this->notifications_read_time = time(); return $this; } @@ -432,7 +432,7 @@ class User extends Model { return $this->notifications() ->whereIn('type', $this->getAlertableNotificationTypes()) - ->where('time', '>', $this->notification_read_time ?: 0) + ->where('time', '>', $this->notifications_read_time ?: 0) ->where('is_read', 0) ->where('is_deleted', 0) ->count($this->getConnection()->raw('DISTINCT type, subject_id'));