diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index fd69eea9..8d5b9dfb 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -260,7 +260,7 @@ class AdminController extends Controller ->setRowId('uid') ->addColumn('operations', app('user.current')->getPermission()) ->addColumn('players_count', function ($user) { - return Player::where('uid', $user->uid)->count(); + return $user->players->count(); }) ->make(true); } diff --git a/tests/AdminControllerTest.php b/tests/AdminControllerTest.php index 56bf5a81..81ebac97 100644 --- a/tests/AdminControllerTest.php +++ b/tests/AdminControllerTest.php @@ -192,7 +192,7 @@ class AdminControllerTest extends BrowserKitTestCase public function testGetPlayerData() { $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; $this->visit('/admin/player-data') ->seeJsonStructure([ diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 32d4fc82..423ce3eb 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -126,7 +126,7 @@ class MiddlewareTest extends TestCase $this->getJson("/{$player->player_name}.json"); $player = factory(\App\Models\Player::class)->create(); - $user = \App\Models\User::find($player->uid); + $user = $player->user; $this->actAs($user) ->postJson('/user/player/rename', [ 'pid' => -1, @@ -148,7 +148,7 @@ class MiddlewareTest extends TestCase { $other_user = factory(\App\Models\User::class)->create(); $player = factory(\App\Models\Player::class)->create(); - $owner = \App\Models\User::find($player->uid); + $owner = $player->user; $this->actAs($other_user) ->get('/user/player') diff --git a/tests/PlayerControllerTest.php b/tests/PlayerControllerTest.php index 9d07877b..76e5fefa 100644 --- a/tests/PlayerControllerTest.php +++ b/tests/PlayerControllerTest.php @@ -103,7 +103,7 @@ class PlayerControllerTest extends TestCase public function testDelete() { $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; $this->expectsEvents(Events\PlayerWillBeDeleted::class); $this->actAs($user) ->postJson('/user/player/delete', ['pid' => $player->pid]) @@ -121,7 +121,7 @@ class PlayerControllerTest extends TestCase // No returning score option(['return_score' => false]); $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; $this->actAs($user) ->postJson('/user/player/delete', ['pid' => $player->pid]) ->assertJson([ @@ -144,7 +144,7 @@ class PlayerControllerTest extends TestCase public function testRename() { $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; // Without new player name $this->actAs($user) @@ -208,7 +208,7 @@ class PlayerControllerTest extends TestCase public function testSetTexture() { $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; $steve = factory(Texture::class)->create(); $alex = factory(Texture::class, 'alex')->create(); $cape = factory(Texture::class, 'cape')->create(); @@ -284,7 +284,7 @@ class PlayerControllerTest extends TestCase public function testClearTexture() { $player = factory(Player::class)->create(); - $user = User::find($player->uid); + $user = $player->user; $player->setTexture([ 'tid_steve' => 1, @@ -314,7 +314,7 @@ class PlayerControllerTest extends TestCase { // Without `preference` field $player = factory(Player::class)->create(); - $this->actAs(User::find($player->uid)) + $this->actAs($player->user) ->postJson('/user/player/preference', [ 'pid' => $player->pid ], [ diff --git a/tests/TextureControllerTest.php b/tests/TextureControllerTest.php index 2bb974e6..92c228f2 100644 --- a/tests/TextureControllerTest.php +++ b/tests/TextureControllerTest.php @@ -22,12 +22,12 @@ class TextureControllerTest extends TestCase // Player is banned $player = factory(Player::class)->create(['tid_steve' => $steve->tid]); - User::find($player->uid)->setPermission(User::BANNED); + $player->user->setPermission(User::BANNED); $this->get("/{$player->player_name}.json") ->assertSee(trans('general.player-banned')) ->assertStatus(403); - User::find($player->uid)->setPermission(User::NORMAL); + $player->user->setPermission(User::NORMAL); // Default API is CSL API $this->getJson("/{$player->player_name}.json")