clean up
This commit is contained in:
parent
5e051eadfe
commit
88d9901e77
|
|
@ -456,37 +456,6 @@ class AdminController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
public function getPlayerData(Request $request)
|
||||
{
|
||||
$isSpecifiedUser = $request->has('uid');
|
||||
|
||||
if ($isSpecifiedUser) {
|
||||
$players = Player::select(['pid', 'uid', 'name', 'tid_skin', 'tid_cape', 'last_modified'])
|
||||
->where('uid', intval($request->input('uid')))
|
||||
->get();
|
||||
} else {
|
||||
$search = $request->input('search', '');
|
||||
$sortField = $request->input('sortField', 'pid');
|
||||
$sortType = $request->input('sortType', 'asc');
|
||||
$page = $request->input('page', 1);
|
||||
$perPage = $request->input('perPage', 10);
|
||||
|
||||
$players = Player::select(['pid', 'uid', 'name', 'tid_skin', 'tid_cape', 'last_modified'])
|
||||
->where('pid', 'like', '%'.$search.'%')
|
||||
->orWhere('uid', 'like', '%'.$search.'%')
|
||||
->orWhere('name', 'like', '%'.$search.'%')
|
||||
->orderBy($sortField, $sortType)
|
||||
->offset(($page - 1) * $perPage)
|
||||
->limit($perPage)
|
||||
->get();
|
||||
}
|
||||
|
||||
return [
|
||||
'totalRecords' => $isSpecifiedUser ? 1 : Player::count(),
|
||||
'data' => $players,
|
||||
];
|
||||
}
|
||||
|
||||
public function userAjaxHandler(Request $request)
|
||||
{
|
||||
$action = $request->input('action');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Tests;
|
||||
|
||||
use App\Models\Player;
|
||||
use App\Models\Texture;
|
||||
use App\Models\User;
|
||||
use App\Services\Plugin;
|
||||
|
|
@ -94,40 +93,6 @@ class AdminControllerTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testPlayers()
|
||||
{
|
||||
$this->get('/admin/players')->assertSee(trans('general.player-manage'));
|
||||
}
|
||||
|
||||
public function testGetPlayerData()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
$user = $player->user;
|
||||
|
||||
$this->getJson('/admin/players/list')
|
||||
->assertJsonStructure([
|
||||
'data' => [[
|
||||
'pid',
|
||||
'uid',
|
||||
'name',
|
||||
'tid_skin',
|
||||
'tid_cape',
|
||||
'last_modified',
|
||||
]],
|
||||
]);
|
||||
|
||||
$this->getJson('/admin/players/list?uid='.$user->uid)
|
||||
->assertJson([
|
||||
'data' => [[
|
||||
'pid' => $player->pid,
|
||||
'uid' => $user->uid,
|
||||
'name' => $player->name,
|
||||
'tid_skin' => $player->tid_skin,
|
||||
'tid_cape' => $player->tid_cape,
|
||||
]],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testUserAjaxHandler()
|
||||
{
|
||||
// Operate on an not-existed user
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user