working on events & data adapter

This commit is contained in:
printempw 2016-10-30 11:57:26 +08:00
parent 167c40f550
commit 6aaec6f658
7 changed files with 15 additions and 37 deletions

View File

@ -11,7 +11,7 @@ class ConfigureUserMenu extends Event
*
* @return void
*/
public function __construct(Array &$menu)
public function __construct(array &$menu)
{
// pass array by reference
$this->menu = &$menu;

View File

@ -1,7 +0,0 @@
<?php
/**
* @Author: printempw
* @Date: 2016-10-17 14:12:54
* @Last Modified by: printempw
* @Last Modified time: 2016-10-17 14:13:00
*/

View File

@ -1,23 +0,0 @@
<?php
namespace App\Events;
use Illuminate\Queue\SerializesModels;
class UserInstantiated extends Event
{
use SerializesModels;
public $uid;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($uid)
{
$this->uid = $uid;
}
}

View File

@ -10,7 +10,7 @@ class UserTryToLogin extends Event
public $identification;
public $auth_type;
public $authType;
/**
* Create a new event instance.
@ -20,7 +20,7 @@ class UserTryToLogin extends Event
public function __construct($identification, $auth_type)
{
$this->identification = $identification;
$this->auth_type = $auth_type;
$this->authType = $auth_type;
}
}

View File

@ -12,6 +12,7 @@ use App\Models\Texture;
use Illuminate\Http\Request;
use App\Events\PlayerWasAdded;
use App\Events\PlayerWasDeleted;
use App\Events\CheckPlayerExists;
use App\Exceptions\PrettyPageException;
use App\Services\Repositories\UserRepository;
@ -50,6 +51,8 @@ class PlayerController extends Controller
'player_name' => 'required|'.(Option::get('allow_chinese_playername') == "1") ? 'pname_chinese' : 'player_name'
]);
Event::fire(new CheckPlayerExists($request->input('player_name')));
if (!Player::where('player_name', $request->input('player_name'))->get()->isEmpty()) {
return json(trans('user.player.add.repeated'), 6);
}

View File

@ -7,6 +7,7 @@ use Option;
use Storage;
use Response;
use Minecraft;
use Carbon\Carbon;
use App\Models\User;
use App\Models\Player;
use App\Models\Texture;
@ -30,12 +31,16 @@ class TextureController extends Controller
$player = $this->getPlayerInstance($player_name);
if ($api == "csl") {
return Response::rawJson($player->getJsonProfile(Player::CSL_API));
$content = $player->getJsonProfile(Player::CSL_API);
} else if ($api == "usm") {
return Response::rawJson($player->getJsonProfile(Player::USM_API));
$content = $player->getJsonProfile(Player::USM_API);
} else {
return Response::rawJson($player->getJsonProfile(Option::get('api_type')));
$content = $player->getJsonProfile(Option::get('api_type'));
}
return Response::rawJson($content, 200, [
'Last-Modified' => Carbon::createFromTimestamp($player->getLastModified())->format('D, d M Y H:i:s \G\M\T')
]);
}
public function jsonWithApi($api, $player_name)

View File

@ -58,7 +58,7 @@ class Database
public function table($table_name, $no_prefix = false)
{
if ($this->connection->real_escape_string($table_name) == $table_name) {
$this->table_name = $no_prefix ? $table_name : config('database.connections.mysql.prefix').$table_name;
$this->table_name = $no_prefix ? "{$this->config['database']}.$table_name" : config('database.connections.mysql.prefix').$table_name;
return $this;
} else {
throw new \InvalidArgumentException('Table name contains invalid characters', 1);