diff --git a/app/Models/Closet.php b/app/Models/Closet.php index 752bd983..ebfb0d13 100644 --- a/app/Models/Closet.php +++ b/app/Models/Closet.php @@ -190,11 +190,21 @@ class Closet return ! Texture::where('tid', $tid)->isEmpty(); } - private function save() + /** + * Set textures string manually. + * + * @param string $textures + */ + public function setTextures($textures) + { + return $this->db->where('uid', $this->uid)->update(['textures' => $textures]);; + } + + public function save() { if (empty($this->items_modified)) return; - $this->db->where('uid', $this->uid)->update(['textures' => json_encode($this->textures)]); + return $this->setTextures(json_encode($this->textures)); } public function __destruct() diff --git a/config/menu.php b/config/menu.php index 3dbe0688..31596a9f 100644 --- a/config/menu.php +++ b/config/menu.php @@ -23,6 +23,7 @@ $menu['admin'] = array( ['title' => 'general.customize', 'link' => 'admin/customize', 'icon' => 'fa-paint-brush'], ['title' => 'general.score-options', 'link' => 'admin/score', 'icon' => 'fa-credit-card'], ['title' => 'general.options', 'link' => 'admin/options', 'icon' => 'fa-cog'], + ['title' => 'general.import-v2', 'link' => 'setup/migrations', 'icon' => 'fa-undo'], ['title' => 'general.check-update', 'link' => 'admin/update', 'icon' => 'fa-arrow-up'] ); diff --git a/resources/lang/en/general.yml b/resources/lang/en/general.yml index 68427ca6..ba38fb75 100644 --- a/resources/lang/en/general.yml +++ b/resources/lang/en/general.yml @@ -18,6 +18,7 @@ user-manage: User Manage generate-config: Generate Config customize: Customize options: Options +import-v2: Import Data score-options: Score Options check-update: Check Update download-update: Download Updates diff --git a/resources/lang/zh-CN/general.yml b/resources/lang/zh-CN/general.yml index a4071c50..2d6267fd 100644 --- a/resources/lang/zh-CN/general.yml +++ b/resources/lang/zh-CN/general.yml @@ -18,6 +18,7 @@ user-manage: 用户管理 generate-config: 配置生成 customize: 个性化 options: 站点配置 +import-v2: 导入数据 score-options: 积分配置 check-update: 检查更新 download-update: 下载更新 diff --git a/setup/migrations/import_v2_both.php b/setup/migrations/import_v2_both.php index 8c2eed5d..b06cde8b 100644 --- a/setup/migrations/import_v2_both.php +++ b/setup/migrations/import_v2_both.php @@ -3,12 +3,12 @@ * @Author: printempw * @Date: 2016-08-18 17:46:19 * @Last Modified by: printempw - * @Last Modified time: 2016-09-14 19:44:05 + * @Last Modified time: 2016-10-16 20:23:12 */ use App\Models\UserModel; -use App\Models\PlayerModel; -use App\Models\ClosetModel; +use App\Models\Player; +use App\Models\Closet; use App\Models\Texture; if (!defined('BASE_DIR')) exit('Permission denied.'); @@ -45,7 +45,7 @@ for ($i = 0; $i <= $steps; $i++) { // compile patterns $name = str_replace('{username}', $row['username'], $_POST['texture_name_pattern']); - if (PlayerModel::where('player_name', $row['username'])->get()->isEmpty()) { + if (Player::where('player_name', $row['username'])->get()->isEmpty()) { $user = new UserModel; $user->email = ''; @@ -96,17 +96,14 @@ for ($i = 0; $i <= $steps; $i++) { } } - $p = new PlayerModel; + $p = new Player; $p->uid = $user->uid; $p->player_name = $row['username']; $p->preference = $row['preference']; $p->last_modified = $row['last_modified'] ? : Utils::getTimeFormatted(); - $c = new ClosetModel; - - $c->uid = $user->uid; - $c->textures = ''; + $c = new Closet($user->uid); $items = []; @@ -121,10 +118,7 @@ for ($i = 0; $i <= $steps; $i++) { ); } - $c->textures = json_encode($items); - - $p->save(); - $c->save(); + $c->setTextures(json_encode($items)); $user_imported++; // echo $row['username']." saved.
";