Feat: 商店功能完整实现(单次特效卡888/周卡8888/改名卡5000,含购买、周卡覆盖、改名黑名单)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:用户名黑名单模型
|
||||
* 用户改名后旧名称写入此表,保留期间其他人无法注册该名称
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UsernameBlacklist extends Model
|
||||
{
|
||||
protected $table = 'username_blacklist';
|
||||
|
||||
public $timestamps = false; // 只有 created_at 无 updated_at
|
||||
|
||||
protected $fillable = ['username', 'reserved_until', 'created_at'];
|
||||
|
||||
protected $casts = [
|
||||
'reserved_until' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* 判断给定名称是否在黑名单有效期内
|
||||
*/
|
||||
public static function isReserved(string $username): bool
|
||||
{
|
||||
return static::where('username', $username)
|
||||
->where('reserved_until', '>', now())
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user