App\Http\Controllers\PlayerController::rename PHP Method

rename() public method

public rename ( Illuminate\Http\Request $request )
$request Illuminate\Http\Request
    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);
    }