From 99117cca5801b651f23d6dbc1dec16f3a80bf516 Mon Sep 17 00:00:00 2001 From: Tokumeikoi Date: Sun, 26 Apr 2020 19:15:13 +0800 Subject: [PATCH] update --- app/Services/ServerService.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index d7c9d4fc..34405ca2 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -138,23 +138,12 @@ class ServerService public function log(int $userId, int $serverId, int $u, int $d, float $rate) { - $serverLog = ServerLog::where('user_id', $userId) - ->where('server_id', $serverId) - ->where('created_at', '>=', strtotime(date('Y-m-d h:00:00'))) - ->orderBy('created_at', 'DESC') - ->first(); - if ($serverLog) { - $serverLog->u = $serverLog->u + $u; - $serverLog->d = $serverLog->d + $d; - $serverLog->save(); - } else { - $serverLog = new ServerLog(); - $serverLog->user_id = $userId; - $serverLog->server_id = $serverId; - $serverLog->u = $u; - $serverLog->d = $d; - $serverLog->rate = $rate; - $serverLog->save(); - } + $serverLog = new ServerLog(); + $serverLog->user_id = $userId; + $serverLog->server_id = $serverId; + $serverLog->u = $u; + $serverLog->d = $d; + $serverLog->rate = $rate; + $serverLog->save(); } }