Skip to content

Commit

Permalink
Fix migration dropping wrong table.
Browse files Browse the repository at this point in the history
Code formattting.
  • Loading branch information
furic committed Dec 19, 2020
1 parent cfad8e4 commit 52b45b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion migrations/2017_08_07_081215_create_game_player_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('player_games');
Schema::dropIfExists('game_player');
}

}
12 changes: 6 additions & 6 deletions src/Http/Controllers/GameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function show($id)
return response(Game::findOrFail($id), 200);
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return response([
'error' => 'No game found.'
'error' => 'Game not found.'
], 400);
}
}
Expand All @@ -43,7 +43,7 @@ public function showVersions($id) // Depricated
], 200);
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return response([
'error' => 'No game found.'
'error' => 'Game not found.'
], 400);
}
}
Expand All @@ -58,14 +58,14 @@ public function showVersions($id) // Depricated
public function showPlayers(Request $request, $id)
{
try {
if ($request->limit <= 0) {
return response(Game::findOrFail($id)->players, 200);
if ($request->filled('limit') && $request->limit > 0) {
return response(Game::findOrFail($id)->players()->take($request->limit)->get(), 200);
} else {
return response(Game::findOrFail($id)->players->take($request->limit), 200);
return response(Game::findOrFail($id)->players()->take(100)->get(), 200); // Max 100 records to avoid memory exhauseted
}
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return response([
'error' => 'No game found.'
'error' => 'Game not found.'
], 400);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/GamePlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GamePlayer extends Model

protected $table = 'game_player';

protected $fillable = ['player_id', 'game_id', 'is_online', 'channel', 'version', 'is_hack'];
protected $fillable = ['game_id', 'player_id', 'is_online', 'channel', 'version', 'is_hack'];

public static function findByGamePlayer($gameId, $playerId)
{
Expand Down

0 comments on commit 52b45b6

Please sign in to comment.