From b8b8a8493cff2c1332167713dcd8f130b744569d Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 31 Mar 2019 23:55:07 +0800 Subject: [PATCH] Add getter for compat --- app/Models/Player.php | 11 +++++++++++ tests/ModelsTest/PlayerTest.php | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/app/Models/Player.php b/app/Models/Player.php index 16e610b2..5d3c0d65 100644 --- a/app/Models/Player.php +++ b/app/Models/Player.php @@ -94,4 +94,15 @@ class Player extends Model return json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); } + + /** + * TODO: This is only for compatibility of 3rd plugins. + * Remove this in next major version. + * + * @deprecated + */ + public function getPlayerNameAttribute() + { + return $this->name; + } } diff --git a/tests/ModelsTest/PlayerTest.php b/tests/ModelsTest/PlayerTest.php index c28f538c..373ca7d2 100644 --- a/tests/ModelsTest/PlayerTest.php +++ b/tests/ModelsTest/PlayerTest.php @@ -29,4 +29,10 @@ class PlayerTest extends TestCase $player = factory(Player::class)->make(); $this->assertNull($player->getJsonProfile(-1)); } + + public function testGetPlayerName() + { + $player = factory(Player::class)->make(); + $this->assertEquals($player->name, $player->player_name); + } }