@@ -14,7 +14,7 @@ |
||
| 14 | 14 | { |
| 15 | 15 | factory(Leaderboard::class, 5) |
| 16 | 16 | ->create() |
| 17 | - ->each(function (Leaderboard $leaderboard) { |
|
| 17 | + ->each(function(Leaderboard $leaderboard) { |
|
| 18 | 18 | $leaderboard->game_id = rand(1, 3); |
| 19 | 19 | }); |
| 20 | 20 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | use Furic\Leaderboards\Http\Controllers\LeaderboardController; |
| 5 | 5 | |
| 6 | 6 | Route::prefix('api')->group(function() { |
| 7 | - Route::get('leaderboards/{id}', [LeaderboardController::class, 'show']); |
|
| 7 | + Route::get('leaderboards/{id}', [LeaderboardController::class, 'show']); |
|
| 8 | 8 | Route::get('leaderboards/{id}/current', [LeaderboardController::class, 'showCurrent']); |
| 9 | 9 | Route::get('leaderboards/{id}/score-sums', [LeaderboardController::class, 'showScoreSums']); |
| 10 | 10 | Route::get('leaderboards/{id}/highscores', [LeaderboardController::class, 'showHighscores']); |
@@ -338,8 +338,9 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | $playerReward = LeaderboardPlayerReward::where('player_id', $request->player_id)->where('leaderboard_timescope_id', $leaderboardTimescope->id)->whereNotNull('score_sum'); |
| 341 | - if (!$playerReward) |
|
| 342 | - $playerReward = LeaderboardPlayerReward::make(['leaderboard_timescope_id' => $leaderboardTimescope->id, 'player_id' => $request->player_id]); |
|
| 341 | + if (!$playerReward) { |
|
| 342 | + $playerReward = LeaderboardPlayerReward::make(['leaderboard_timescope_id' => $leaderboardTimescope->id, 'player_id' => $request->player_id]); |
|
| 343 | + } |
|
| 343 | 344 | $playerReward->score_sum = $rewardedScore; |
| 344 | 345 | $playerReward->save(); |
| 345 | 346 | } |
@@ -347,8 +348,9 @@ discard block |
||
| 347 | 348 | // Rank reward only report to last LeaderboardTimescope |
| 348 | 349 | |
| 349 | 350 | // dd ($leaderboardTimescope->previous()); |
| 350 | - if ($leaderboardTimescope->previous() != null) |
|
| 351 | - $leaderboardTimescope = $leaderboardTimescope->previous(); |
|
| 351 | + if ($leaderboardTimescope->previous() != null) { |
|
| 352 | + $leaderboardTimescope = $leaderboardTimescope->previous(); |
|
| 353 | + } |
|
| 352 | 354 | |
| 353 | 355 | $playerReward = LeaderboardPlayerReward::firstOrNew(['player_id' => $request->player_id, 'leaderboard_timescope_id' => $leaderboardTimescope->id]); |
| 354 | 356 | if ($request->has('rank')) { |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | |
| 72 | 72 | public function getHighscoreRank($highscore) |
| 73 | 73 | { |
| 74 | - return $this->hasMany(LeaderboardScore::class)->filter(function ($score) { |
|
| 74 | + return $this->hasMany(LeaderboardScore::class)->filter(function($score) { |
|
| 75 | 75 | return $score['highscore'] > $highscore; |
| 76 | 76 | }); |
| 77 | 77 | } |
@@ -37,8 +37,9 @@ |
||
| 37 | 37 | break; |
| 38 | 38 | } |
| 39 | 39 | $previousLeaderboardTimescope = SELF::where('start_at', '<', $data['start_at'])->orderBy('start_at', 'desc')->first(); |
| 40 | - if ($previousLeaderboardTimescope) |
|
| 41 | - $data['previous_id'] = $previousLeaderboardTimescope->id; |
|
| 40 | + if ($previousLeaderboardTimescope) { |
|
| 41 | + $data['previous_id'] = $previousLeaderboardTimescope->id; |
|
| 42 | + } |
|
| 42 | 43 | $leaderboardTimescope = SELF::create($data); |
| 43 | 44 | } |
| 44 | 45 | return $leaderboardTimescope; |
@@ -29,8 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function getNameAttribute() |
| 31 | 31 | { |
| 32 | - if ($this->player != null) |
|
| 33 | - return $this->player->name; |
|
| 32 | + if ($this->player != null) { |
|
| 33 | + return $this->player->name; |
|
| 34 | + } |
|
| 34 | 35 | return NULL; |
| 35 | 36 | // return $this->player()->firstOrFail()->name; |
| 36 | 37 | } |