Add getter for compat

This commit is contained in:
Pig Fang 2019-03-31 23:55:07 +08:00
parent 6d5ab8ed2e
commit b8b8a8493c
2 changed files with 17 additions and 0 deletions

View File

@ -94,4 +94,15 @@ class Player extends Model
return json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); 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;
}
} }

View File

@ -29,4 +29,10 @@ class PlayerTest extends TestCase
$player = factory(Player::class)->make(); $player = factory(Player::class)->make();
$this->assertNull($player->getJsonProfile(-1)); $this->assertNull($player->getJsonProfile(-1));
} }
public function testGetPlayerName()
{
$player = factory(Player::class)->make();
$this->assertEquals($player->name, $player->player_name);
}
} }