setTable(plugin()->webman->config('database.player_game_record_table')); } /** * 上分 * * @param $value * @return float */ public function getOpenPointAttribute($value): float { return floatval($value); } /** * 下分 * * @param $value * @return float */ public function getWashPointAttribute($value): float { return floatval($value); } /** * 余点数 * * @param $value * @return float */ public function getAfterGameAmountAttribute($value): float { return floatval($value); } /** * 机台信息 * @return BelongsTo */ public function machine(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.machine_model'), 'machine_id')->withTrashed(); } /** * 玩家信息 * @return BelongsTo */ public function player(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.player_model'), 'player_id')->withTrashed(); } /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { if (config('app.profit', 'task') == 'event') { static::updated(function (PlayerGameRecord $playerGameRecord) { $oldStatus = $playerGameRecord->getOriginal('status'); // 原始值 $newStatus = $playerGameRecord->status; // 游戏结束并且产生盈亏后计算分润 if ($oldStatus != $newStatus && $newStatus == PlayerGameRecord::STATUS_END && $playerGameRecord->open_point != $playerGameRecord->wash_point) { Event::emit('promotion.playerGame', $playerGameRecord); } }); } } public function last_player_game_log(): HasOne { return $this->hasOne(PlayerGameLog::class, 'game_record_id')->latest(); } }