rename() public method

Rename the player.
public rename ( string $new_name ) : mixed
$new_name string
return mixed
 public function rename(Request $request)
 {
     $this->validate($request, ['new_player_name' => 'required|' . (option('allow_chinese_playername') ? 'pname_chinese' : 'playername')]);
     $new_name = $request->input('new_player_name');
     if (!Player::where('player_name', $new_name)->get()->isEmpty()) {
         return json(trans('user.player.rename.repeated'), 6);
     }
     $old_name = $this->player->player_name;
     $this->player->rename($new_name);
     return json(trans('user.player.rename.success', ['old' => $old_name, 'new' => $new_name]), 0);
 }