Skip to content

Commit

Permalink
修正 创建标记垃圾时未记录时间的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
imdong committed Oct 21, 2023
1 parent 0004cc3 commit e7d7713
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// 添加文章的关联查询
(new Extend\Model(Post::class))
// 标记过垃圾的用户列表
->belongsToMany('spams', User::class, 'post_spams', 'post_id', 'create_user_id')
->belongsToMany('spams', User::class, PostSpam::class, 'post_id', 'create_user_id')
->cast('is_spam_hide', 'boolean')
,

Expand Down
2 changes: 1 addition & 1 deletion migrations/2023_10_21_000000_create_post_spams_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function (Blueprint $table) {
$table->integer('create_user_id')->unsigned();
$table->primary(['post_id', 'create_user_id']);

$table->timestamp('created_at')->nullable();
$table->timestamp('created_at')->nullable()->useCurrent();
}
);

19 changes: 19 additions & 0 deletions src/PostSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,23 @@ class PostSpam extends AbstractModel
// See https://docs.flarum.org/extend/models.html#backend-models for more information.

protected $table = 'post_spams';

/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;

/**
* Get the name of the "updated at" column.
*
* 不需要更新时间字段
*
* @return string|null
*/
public function getUpdatedAtColumn()
{
return null;
}
}

0 comments on commit e7d7713

Please sign in to comment.