@@ -56,7 +56,7 @@ |
||
| 56 | 56 | { |
| 57 | 57 | DB::table('game_codes')->delete(); |
| 58 | 58 | DB::table('users_codes')->delete(); |
| 59 | - DB::table('game_admin')->delete(); |
|
| 59 | + DB::table('game_admin')->delete(); |
|
| 60 | 60 | |
| 61 | 61 | DB::update('UPDATE users SET rank = NULL;'); |
| 62 | 62 | DB::update('UPDATE users SET total_points = NULL;'); |
@@ -20,27 +20,27 @@ |
||
| 20 | 20 | return intval($codeCount); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Anzahl codes aus DB holen und ausgeben |
|
| 25 | - * |
|
| 26 | - * @return mixed |
|
| 27 | - */ |
|
| 28 | - public static function getCodeCount() |
|
| 23 | + /** |
|
| 24 | + * Anzahl codes aus DB holen und ausgeben |
|
| 25 | + * |
|
| 26 | + * @return mixed |
|
| 27 | + */ |
|
| 28 | + public static function getCodeCount() |
|
| 29 | 29 | { |
| 30 | 30 | $codeCount = DB::table('game_admin')->select('code_count')->first()->code_count; |
| 31 | 31 | |
| 32 | 32 | return $codeCount; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Anzahl codes aus DB holen und ausgeben |
|
| 37 | - * |
|
| 38 | - * @return mixed |
|
| 39 | - */ |
|
| 40 | - public static function getTotalPoints() |
|
| 41 | - { |
|
| 42 | - $totalPoints = DB::table('game_admin')->select('total_points')->first()->total_points; |
|
| 43 | - |
|
| 44 | - return $totalPoints; |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * Anzahl codes aus DB holen und ausgeben |
|
| 37 | + * |
|
| 38 | + * @return mixed |
|
| 39 | + */ |
|
| 40 | + public static function getTotalPoints() |
|
| 41 | + { |
|
| 42 | + $totalPoints = DB::table('game_admin')->select('total_points')->first()->total_points; |
|
| 43 | + |
|
| 44 | + return $totalPoints; |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -23,12 +23,12 @@ |
||
| 23 | 23 | |
| 24 | 24 | private function setRank() |
| 25 | 25 | { |
| 26 | - $totalPoints = CodeCount::getTotalPoints(); |
|
| 27 | - $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
|
| 26 | + $totalPoints = CodeCount::getTotalPoints(); |
|
| 27 | + $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
|
| 28 | 28 | |
| 29 | - for($i = 0; $i < count($rankObj); $i++){ |
|
| 30 | - DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
|
| 31 | - $i--; |
|
| 32 | - } |
|
| 29 | + for($i = 0; $i < count($rankObj); $i++){ |
|
| 30 | + DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
|
| 31 | + $i--; |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $totalPoints = CodeCount::getTotalPoints(); |
| 27 | 27 | $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
| 28 | 28 | |
| 29 | - for($i = 0; $i < count($rankObj); $i++){ |
|
| 29 | + for ($i = 0; $i < count($rankObj); $i++) { |
|
| 30 | 30 | DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
| 31 | 31 | $i--; |
| 32 | 32 | } |
@@ -8,25 +8,25 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function ranking() |
| 10 | 10 | { |
| 11 | - $this->setRank(); |
|
| 11 | + $this->setRank(); |
|
| 12 | 12 | |
| 13 | - $rankObj = DB::select('SELECT * FROM users WHERE total_points > 0 ORDER BY total_points DESC,rank;'); |
|
| 14 | - $rankArray = json_decode(json_encode($rankObj), true); |
|
| 15 | - $userRank = count($rankArray); |
|
| 13 | + $rankObj = DB::select('SELECT * FROM users WHERE total_points > 0 ORDER BY total_points DESC,rank;'); |
|
| 14 | + $rankArray = json_decode(json_encode($rankObj), true); |
|
| 15 | + $userRank = count($rankArray); |
|
| 16 | 16 | |
| 17 | - return view('leader.ranking', ['rankArray' => $rankArray, 'userRank' => $userRank]); |
|
| 17 | + return view('leader.ranking', ['rankArray' => $rankArray, 'userRank' => $userRank]); |
|
| 18 | 18 | |
| 19 | 19 | return view('leader.ranking', ['rankArray' => $rankArray, 'userRank' => $userRank])->renderSections()['dynamicRanking']; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - private function setRank() |
|
| 23 | - { |
|
| 24 | - $totalPoints = CodeCount::getTotalPoints(); |
|
| 25 | - $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
|
| 22 | + private function setRank() |
|
| 23 | + { |
|
| 24 | + $totalPoints = CodeCount::getTotalPoints(); |
|
| 25 | + $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
|
| 26 | 26 | |
| 27 | - for($i = 0; $i < count($rankObj); $i++){ |
|
| 28 | - DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
|
| 29 | - $i--; |
|
| 30 | - } |
|
| 31 | - } |
|
| 27 | + for($i = 0; $i < count($rankObj); $i++){ |
|
| 28 | + DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
|
| 29 | + $i--; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | $totalPoints = CodeCount::getTotalPoints(); |
| 25 | 25 | $rankObj = DB::select('SELECT * FROM users WHERE total_points = '.$totalPoints.' ORDER BY TIMEDIFF(start, end) DESC;'); |
| 26 | 26 | |
| 27 | - for($i = 0; $i < count($rankObj); $i++){ |
|
| 27 | + for ($i = 0; $i < count($rankObj); $i++) { |
|
| 28 | 28 | DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]); |
| 29 | 29 | $i--; |
| 30 | 30 | } |