Rename column for consistency

This commit is contained in:
Toby Zerner 2015-09-22 16:54:32 +09:30
parent 2976541d5c
commit d4dda26383
3 changed files with 37 additions and 3 deletions

View File

@ -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))

View File

@ -0,0 +1,33 @@
<?php
namespace Flarum\Migrations\Core;
use Illuminate\Database\Schema\Blueprint;
use Flarum\Migrations\Migration;
class RenameNotificationReadTime extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$this->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');
});
}
}

View File

@ -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'));