2016-07-22 19:36:24 +08:00
|
|
|
<?php
|
|
|
|
|
2016-08-28 10:05:21 +08:00
|
|
|
namespace App\Http\Controllers;
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
use View;
|
|
|
|
use Utils;
|
2016-11-12 23:50:41 +08:00
|
|
|
use Option;
|
2016-12-31 11:38:07 +08:00
|
|
|
use Datatables;
|
2016-11-19 22:02:02 +08:00
|
|
|
use App\Events;
|
2016-07-22 19:36:24 +08:00
|
|
|
use App\Models\User;
|
2016-07-23 15:20:10 +08:00
|
|
|
use App\Models\Player;
|
|
|
|
use App\Models\Texture;
|
2016-12-31 11:38:07 +08:00
|
|
|
use Illuminate\Support\Arr;
|
2016-09-04 15:35:12 +08:00
|
|
|
use Illuminate\Http\Request;
|
2016-12-31 23:28:09 +08:00
|
|
|
use App\Services\OptionForm;
|
2016-08-29 19:47:30 +08:00
|
|
|
use App\Exceptions\PrettyPageException;
|
2016-10-23 11:41:52 +08:00
|
|
|
use App\Services\Repositories\UserRepository;
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
class AdminController extends Controller
|
2016-07-22 19:36:24 +08:00
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2016-08-28 10:05:21 +08:00
|
|
|
return view('admin.index');
|
2016-07-22 19:36:24 +08:00
|
|
|
}
|
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
public function customize(Request $request)
|
2016-07-23 15:20:10 +08:00
|
|
|
{
|
2016-12-31 21:16:04 +08:00
|
|
|
if ($request->input('action') == "color") {
|
|
|
|
$this->validate($request, [
|
|
|
|
'color_scheme' => 'required'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$color_scheme = str_replace('_', '-', $request->input('color_scheme'));
|
|
|
|
option(['color_scheme' => $color_scheme]);
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
return json(trans('admin.customize.change-color.success'), 0);
|
2016-12-31 21:16:04 +08:00
|
|
|
}
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$homepage = Option::form('homepage', OptionForm::AUTO_DETECT, function($form)
|
2016-12-27 23:05:09 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('home_pic_url')->hint(OptionForm::AUTO_DETECT);
|
2016-12-27 23:05:09 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('favicon_url')->hint(OptionForm::AUTO_DETECT)
|
|
|
|
->description(OptionForm::AUTO_DETECT);
|
2016-12-31 13:36:46 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->select('copyright_prefer')
|
2016-12-30 20:55:33 +08:00
|
|
|
->option('0', 'Powered with ❤ by Blessing Skin Server.')
|
|
|
|
->option('1', 'Powered by Blessing Skin Server.')
|
2016-12-31 23:28:09 +08:00
|
|
|
->option('2', 'Proudly powered by Blessing Skin Server.')
|
|
|
|
->option('3', '由 Blessing Skin Server 强力驱动.')
|
|
|
|
->option('4', '自豪地采用 Blessing Skin Server.')
|
|
|
|
->description(OptionForm::AUTO_DETECT);
|
2016-12-29 23:14:09 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->textarea('copyright_text')->rows(6)
|
|
|
|
->description(OptionForm::AUTO_DETECT);
|
2016-12-27 23:05:09 +08:00
|
|
|
|
|
|
|
})->handle();
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$customJsCss = Option::form('customJsCss', OptionForm::AUTO_DETECT, function($form)
|
2016-12-29 23:14:09 +08:00
|
|
|
{
|
|
|
|
$form->textarea('custom_css', 'CSS')->rows(6);
|
|
|
|
$form->textarea('custom_js', 'JavaScript')->rows(6);
|
2016-12-31 23:28:09 +08:00
|
|
|
})->addMessage(OptionForm::AUTO_DETECT)->handle();
|
2016-12-29 23:14:09 +08:00
|
|
|
|
|
|
|
return view('admin.customize', ['forms' => compact('homepage', 'customJsCss')]);
|
2016-07-23 15:20:10 +08:00
|
|
|
}
|
|
|
|
|
2016-07-29 11:52:45 +08:00
|
|
|
public function score()
|
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$rate = Option::form('rate', OptionForm::AUTO_DETECT, function($form)
|
2016-12-21 22:53:53 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('score_per_storage')->text('score_per_storage')->addon(OptionForm::AUTO_DETECT);
|
2016-12-21 22:53:53 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('private_score_per_storage')
|
|
|
|
->text('private_score_per_storage')->addon(OptionForm::AUTO_DETECT)
|
|
|
|
->hint(OptionForm::AUTO_DETECT);
|
2016-12-21 22:53:53 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('score_per_closet_item')
|
|
|
|
->text('score_per_closet_item')->addon(OptionForm::AUTO_DETECT);
|
2016-12-28 13:08:17 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('return_score')->label(OptionForm::AUTO_DETECT);
|
2016-12-21 22:53:53 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('score_per_player')->text('score_per_player')->addon(OptionForm::AUTO_DETECT);
|
2016-12-21 22:53:53 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('user_initial_score');
|
2016-12-21 22:53:53 +08:00
|
|
|
|
|
|
|
})->handle();
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$signIn = Option::form('sign_in', OptionForm::AUTO_DETECT, function($form)
|
2016-12-29 23:14:09 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('sign_score')
|
|
|
|
->text('sign_score_from')->addon(trans('options.sign_score.addon1'))
|
|
|
|
->text('sign_score_to')->addon(trans('options.sign_score.addon2'));
|
2016-12-29 23:14:09 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('sign_gap_time')->text('sign_gap_time')->addon(OptionForm::AUTO_DETECT);
|
2016-12-29 23:14:09 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('sign_after_zero')->label(OptionForm::AUTO_DETECT)
|
|
|
|
->hint(OptionForm::AUTO_DETECT);
|
2016-12-29 23:14:09 +08:00
|
|
|
})->handle(function() {
|
|
|
|
$sign_score = $_POST['sign_score_from'].','.$_POST['sign_score_to'];
|
|
|
|
Option::set('sign_score', $sign_score);
|
|
|
|
|
|
|
|
unset($_POST['sign_score_from']);
|
|
|
|
unset($_POST['sign_score_to']);
|
|
|
|
})->with([
|
|
|
|
'sign_score_from' => @explode(',', option('sign_score'))[0],
|
|
|
|
'sign_score_to' => @explode(',', option('sign_score'))[1]
|
|
|
|
]);
|
|
|
|
|
|
|
|
return view('admin.score', ['forms' => compact('rate', 'signIn')]);
|
2016-07-29 11:52:45 +08:00
|
|
|
}
|
|
|
|
|
2016-07-23 15:20:10 +08:00
|
|
|
public function options()
|
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$general = Option::form('general', OptionForm::AUTO_DETECT, function($form)
|
2016-11-12 23:50:41 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('site_name');
|
|
|
|
$form->text('site_description');
|
|
|
|
$form->text('site_url')->hint(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('user_can_register')->label(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('regs_per_ip');
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->group('max_upload_file_size')
|
2016-12-28 23:28:15 +08:00
|
|
|
->text('max_upload_file_size')->addon('KB')
|
2016-12-31 23:28:09 +08:00
|
|
|
->hint(trans('options.max_upload_file_size.hint', ['size' => ini_get('upload_max_filesize')]));
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('allow_chinese_playername')->label(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->select('api_type')
|
2016-12-28 23:28:15 +08:00
|
|
|
->option('0', 'CustomSkinLoader API')
|
|
|
|
->option('1', 'UniversalSkinAPI');
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('auto_del_invalid_texture')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT);
|
2016-12-28 23:28:15 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->textarea('comment_script')->rows(6)->description(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2017-01-14 23:33:01 +08:00
|
|
|
$form->checkbox('allow_sending_statistic')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT);
|
|
|
|
|
2016-11-12 23:50:41 +08:00
|
|
|
})->handle(function() {
|
|
|
|
if (substr($_POST['site_url'], -1) == "/")
|
|
|
|
$_POST['site_url'] = substr($_POST['site_url'], 0, -1);
|
|
|
|
});
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$announ = Option::form('announ', OptionForm::AUTO_DETECT, function($form)
|
2016-12-29 13:11:46 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->textarea('announcement')->description(OptionForm::AUTO_DETECT);
|
2016-12-29 13:11:46 +08:00
|
|
|
|
|
|
|
})->renderWithOutTable()->handle();
|
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$cache = Option::form('cache', OptionForm::AUTO_DETECT, function($form)
|
2016-11-12 23:50:41 +08:00
|
|
|
{
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->checkbox('force_ssl')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT);
|
|
|
|
$form->checkbox('auto_detect_asset_url')->label(OptionForm::AUTO_DETECT)->description(OptionForm::AUTO_DETECT);
|
|
|
|
$form->checkbox('return_200_when_notfound')->label(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
$form->text('cache_expire_time')->hint(OptionForm::AUTO_DETECT);
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
})->type('warning')->hint(OptionForm::AUTO_DETECT)->handle();
|
2016-11-12 23:50:41 +08:00
|
|
|
|
2016-12-31 23:28:09 +08:00
|
|
|
return view('admin.options')->with('forms', compact('general', 'cache', 'announ'));
|
2016-07-23 15:20:10 +08:00
|
|
|
}
|
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
/**
|
|
|
|
* Show Manage Page of Users.
|
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function users(Request $request)
|
2016-07-23 15:20:10 +08:00
|
|
|
{
|
2016-12-31 11:38:07 +08:00
|
|
|
return view('admin.users');
|
|
|
|
}
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-12-31 11:38:07 +08:00
|
|
|
public function getUserData()
|
|
|
|
{
|
|
|
|
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']);
|
|
|
|
|
|
|
|
$permissionTextMap = [
|
2016-12-31 21:16:04 +08:00
|
|
|
User::BANNED => trans('admin.users.status.banned'),
|
|
|
|
User::NORMAL => trans('admin.users.status.normal'),
|
|
|
|
User::ADMIN => trans('admin.users.status.admin'),
|
|
|
|
User::SUPER_ADMIN => trans('admin.users.status.super-admin')
|
2016-12-31 11:38:07 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return Datatables::of($users)->editColumn('email', function ($user) {
|
2016-12-31 21:16:04 +08:00
|
|
|
return $user->email ?: 'EMPTY';
|
2016-12-31 11:38:07 +08:00
|
|
|
})->editColumn('permission', function ($user) use ($permissionTextMap) {
|
|
|
|
return Arr::get($permissionTextMap, $user->permission);
|
|
|
|
})
|
|
|
|
->setRowId('uid')
|
2016-12-31 13:07:00 +08:00
|
|
|
->editColumn('score', 'vendor.admin-operations.users.score')
|
|
|
|
->addColumn('operations', 'vendor.admin-operations.users.operations')
|
2016-12-31 11:38:07 +08:00
|
|
|
->make(true);
|
2016-07-23 15:20:10 +08:00
|
|
|
}
|
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
/**
|
|
|
|
* Show Manage Page of Players.
|
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function players(Request $request)
|
2016-07-23 15:20:10 +08:00
|
|
|
{
|
2016-12-31 13:07:00 +08:00
|
|
|
return view('admin.players');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPlayerData()
|
|
|
|
{
|
|
|
|
$players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified']);
|
|
|
|
|
|
|
|
return Datatables::of($players)->editColumn('preference', 'vendor.admin-operations.players.preference')
|
|
|
|
->setRowId('pid')
|
|
|
|
->addColumn('previews', 'vendor.admin-operations.players.previews')
|
|
|
|
->addColumn('operations', 'vendor.admin-operations.players.operations')
|
|
|
|
->make(true);
|
2016-07-23 15:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle ajax request from /admin/users
|
2016-09-04 15:35:12 +08:00
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
* @return void
|
2016-07-23 15:20:10 +08:00
|
|
|
*/
|
2016-10-23 11:41:52 +08:00
|
|
|
public function userAjaxHandler(Request $request, UserRepository $users)
|
2016-07-22 19:36:24 +08:00
|
|
|
{
|
2016-09-04 15:35:12 +08:00
|
|
|
$action = $request->input('action');
|
2016-12-31 21:16:04 +08:00
|
|
|
$user = $users->get($request->input('uid'));
|
2016-07-29 15:31:05 +08:00
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
if (!$user)
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.users.operations.non-existent'), 1);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
|
|
|
if ($action == "email") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'email' => 'required|email'
|
|
|
|
]);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->setEmail($request->input('email'));
|
|
|
|
|
|
|
|
return json(trans('admin.users.operations.email.success'), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "nickname") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'nickname' => 'required|nickname'
|
|
|
|
]);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->setNickName($request->input('nickname'));
|
|
|
|
|
|
|
|
return json(trans('admin.users.operations.nickname.success', ['new' => $request->input('nickname')]), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "password") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'password' => 'required|min:8|max:16'
|
|
|
|
]);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->changePasswd($request->input('password'));
|
|
|
|
|
|
|
|
return json(trans('admin.users.operations.password.success'), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "score") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'score' => 'required|integer'
|
|
|
|
]);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->setScore($request->input('score'));
|
|
|
|
|
|
|
|
return json(trans('admin.users.operations.score.success'), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "ban") {
|
2016-10-23 11:41:52 +08:00
|
|
|
if ($user->getPermission() == User::ADMIN) {
|
2016-12-31 21:16:04 +08:00
|
|
|
if (app('user.current')->getPermission() != User::SUPER_ADMIN)
|
|
|
|
return json(trans('admin.users.operations.ban.cant-admin'));
|
2016-10-23 11:41:52 +08:00
|
|
|
} elseif ($user->getPermission() == User::SUPER_ADMIN) {
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.users.operations.ban.cant-super-admin'));
|
2016-07-29 15:31:05 +08:00
|
|
|
}
|
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
$permission = $user->getPermission() == User::BANNED ? User::NORMAL : User::BANNED;
|
2016-07-29 15:31:05 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->setPermission($permission);
|
|
|
|
|
|
|
|
return json([
|
|
|
|
'errno' => 0,
|
|
|
|
'msg' => trans('admin.users.operations.ban.'.($permission == User::BANNED ? 'ban' : 'unban').'.success'),
|
|
|
|
'permission' => $user->getPermission()
|
|
|
|
]);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "admin") {
|
2016-12-31 21:16:04 +08:00
|
|
|
if (app('user.current')->getPermission() != User::SUPER_ADMIN)
|
|
|
|
return json(trans('admin.users.operations.admin.cant-set'));
|
2016-07-29 15:31:05 +08:00
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
if ($user->getPermission() == User::SUPER_ADMIN)
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.users.operations.admin.cant-unset'));
|
2016-07-29 15:31:05 +08:00
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
$permission = $user->getPermission() == User::ADMIN ? User::NORMAL : User::ADMIN;
|
2016-07-29 15:31:05 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->setPermission($permission);
|
|
|
|
|
|
|
|
return json([
|
|
|
|
'errno' => 0,
|
|
|
|
'msg' => trans('admin.users.operations.admin.'.($permission == User::ADMIN ? 'set' : 'unset').'.success'),
|
|
|
|
'permission' => $user->getPermission()
|
|
|
|
]);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-08-16 22:52:00 +08:00
|
|
|
} elseif ($action == "delete") {
|
2016-12-31 21:16:04 +08:00
|
|
|
$user->delete();
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.users.operations.delete.success'), 0);
|
2016-07-22 19:36:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-23 15:20:10 +08:00
|
|
|
/**
|
|
|
|
* Handle ajax request from /admin/players
|
|
|
|
*/
|
2016-10-23 11:41:52 +08:00
|
|
|
public function playerAjaxHandler(Request $request, UserRepository $users)
|
2016-07-22 19:36:24 +08:00
|
|
|
{
|
2016-07-23 15:20:10 +08:00
|
|
|
$action = isset($_GET['action']) ? $_GET['action'] : "";
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-10-16 18:16:15 +08:00
|
|
|
$player = Player::find($request->input('pid'));
|
|
|
|
|
|
|
|
if (!$player)
|
|
|
|
abort(404, trans('general.unexistent-player'));
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-07-23 15:20:10 +08:00
|
|
|
if ($action == "preference") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'preference' => 'required|preference'
|
|
|
|
]);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$player->setPreference($request->input('preference'));
|
|
|
|
|
|
|
|
return json(trans('admin.players.preference.success', ['player' => $player->player_name, 'preference' => $request->input('preference')]), 0);
|
2016-07-22 19:36:24 +08:00
|
|
|
|
2016-07-23 15:20:10 +08:00
|
|
|
} elseif ($action == "texture") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
|
|
|
'model' => 'required|model',
|
|
|
|
'tid' => 'required|integer'
|
|
|
|
]);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-09-04 15:35:12 +08:00
|
|
|
if (!Texture::find($request->tid))
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.players.textures.non-existent', ['tid' => $request->tid]), 1);
|
|
|
|
|
|
|
|
$player->setTexture(['tid_'.$request->model => $request->tid]);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.players.textures.success', ['player' => $player->player_name]), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
|
|
|
} elseif ($action == "owner") {
|
2016-09-04 15:35:12 +08:00
|
|
|
$this->validate($request, [
|
2016-09-10 17:52:33 +08:00
|
|
|
'pid' => 'required|integer',
|
|
|
|
'uid' => 'required|integer'
|
2016-09-04 15:35:12 +08:00
|
|
|
]);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
$user = $users->get($request->input('uid'));
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-10-23 11:41:52 +08:00
|
|
|
if (!$user)
|
2016-12-31 21:16:04 +08:00
|
|
|
return json(trans('admin.users.operations.non-existent'), 1);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-12-31 21:16:04 +08:00
|
|
|
$player->setOwner($request->input('uid'));
|
|
|
|
|
|
|
|
return json(trans('admin.players.owner.success', ['player' => $player->player_name, 'user' => $user->getNickName()]), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
|
2016-07-23 21:46:20 +08:00
|
|
|
} elseif ($action == "delete") {
|
2016-12-31 21:16:04 +08:00
|
|
|
$player->delete();
|
|
|
|
|
|
|
|
return json(trans('admin.players.delete.success'), 0);
|
2016-07-23 15:20:10 +08:00
|
|
|
}
|
2016-07-22 19:36:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|