[色子游戏]玩家抽奖记录-优化样式
This commit is contained in:
@@ -44,14 +44,7 @@ class DicePlayRecord extends BaseModel
|
||||
protected $table = 'dice_play_record';
|
||||
|
||||
/**
|
||||
* 奖池名 搜索
|
||||
*/
|
||||
public function searchLotteryNameAttr($query, $value)
|
||||
{
|
||||
$query->where('lottery_name', 'like', '%'.$value.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家
|
||||
* 关联模型 dicePlayer
|
||||
*/
|
||||
public function dicePlayer(): BelongsTo
|
||||
@@ -60,6 +53,7 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖配置
|
||||
* 关联模型 diceRewardConfig
|
||||
*/
|
||||
public function diceRewardConfig(): BelongsTo
|
||||
@@ -68,6 +62,7 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 彩金配置
|
||||
* 关联模型 diceLotteryConfig
|
||||
*/
|
||||
public function diceLotteryConfig(): BelongsTo
|
||||
@@ -75,4 +70,91 @@ class DicePlayRecord extends BaseModel
|
||||
return $this->belongsTo(DiceLotteryConfig::class, 'lottery_config_id', 'id');
|
||||
}
|
||||
|
||||
/** 按玩家用户名模糊(dicePlayer.username) */
|
||||
public function searchUsernameAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DicePlayer::where('username', 'like', '%' . $value . '%')->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('player_id', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
|
||||
/** 按彩金池配置名称模糊(diceLotteryConfig.name) */
|
||||
public function searchLotteryConfigNameAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DiceLotteryConfig::where('name', 'like', '%' . $value . '%')->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('lottery_config_id', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
|
||||
/** 抽奖类型 */
|
||||
public function searchLotteryTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('lottery_type', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 中奖 */
|
||||
public function searchIsWinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('is_win', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 赢取平台币下限 */
|
||||
public function searchWinCoinMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('win_coin', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 赢取平台币上限 */
|
||||
public function searchWinCoinMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('win_coin', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 按奖励配置前端显示文本模糊(diceRewardConfig.ui_text) */
|
||||
public function searchRewardUiTextAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DiceRewardConfig::where('ui_text', 'like', '%' . $value . '%')->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('reward_config_id', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
|
||||
/** 按奖励档位(diceRewardConfig.tier,中奖名 T1-T5) */
|
||||
public function searchRewardTierAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DiceRewardConfig::where('tier', '=', $value)->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('reward_config_id', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user