update init category icon_id

This commit is contained in:
xiaomlove
2021-05-29 21:48:50 +08:00
parent 3a54de8be7
commit 8e35dc0886
5 changed files with 35 additions and 11 deletions
+1 -8
View File
@@ -1,17 +1,10 @@
<?php
use \Illuminate\Database\Capsule\Manager as Capsule;
$config = require ROOT_PATH . 'config/nexus.php';
$connectionMysql = $config['mysql'];
$connectionMysql['driver'] = 'mysql';
$connectionMysql['charset'] = 'utf8mb4';
$connectionMysql['collation'] = 'utf8mb4_unicode_ci';
$capsule = new Capsule;
$connectionName = \Nexus\Database\DB::ELOQUENT_CONNECTION_NAME;
$capsule->addConnection($connectionMysql, $connectionName);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$capsule->getConnection($connectionName)->enableQueryLog();
\Nexus\Database\DB::bootEloquent($connectionMysql);
+17
View File
@@ -2,6 +2,8 @@
namespace Nexus\Database;
use Illuminate\Database\Capsule\Manager as Capsule;
class DB
{
private $driver;
@@ -209,4 +211,19 @@ class DB
return $result;
}
public static function bootEloquent(array $config)
{
$capsule = new Capsule;
$connectionName = self::ELOQUENT_CONNECTION_NAME;
$capsule->addConnection($config, $connectionName);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$capsule->getConnection($connectionName)->enableQueryLog();
}
public static function schema(): \Illuminate\Database\Schema\Builder
{
return Capsule::schema(self::ELOQUENT_CONNECTION_NAME);
}
}
+8
View File
@@ -2,6 +2,8 @@
namespace Nexus\Install;
use App\Models\Category;
use App\Models\Icon;
use Nexus\Database\DB;
class Update extends Install
@@ -62,6 +64,12 @@ class Update extends Install
$id = DB::insert($table, $insert);
$this->doLog("[ADD CUSTOM FIELD MENU] insert: " . json_encode($insert) . " to table: $table, id: $id");
}
if (WITH_LARAVEL && DB::schema()->hasColumn('categories', 'icon_id')) {
$icon = Icon::query()->orderBy('id', 'asc')->first();
if ($icon) {
Category::query()->where('icon_id', 0)->update(['icon_id' => $icon->id]);
}
}
}
}
+1 -1
View File
@@ -214,7 +214,7 @@ if ($currentStep == 5) {
</div>
</div>
<div class="m-10 text-center">
欢迎使用 NexusPHP 安装程序,如有疑问,点击<a href="http://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取帮助。
欢迎使用 NexusPHP 安装程序,如有疑问,点击<a href="https://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取帮助。
</div>
</body>
<script>
+8 -2
View File
@@ -3,10 +3,16 @@ ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
$rootpath = dirname(dirname(__DIR__)) . '/';
define('ROOT_PATH', $rootpath);
define('IN_NEXUS', true);
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
require $rootpath . 'vendor/autoload.php';
require $rootpath . 'nexus/Database/helpers.php';
require $rootpath . 'include/constants.php';
$withLaravel = false;
if (file_exists($rootpath . '.env')) {
require $rootpath . 'include/eloquent.php';
$withLaravel = true;
}
define('WITH_LARAVEL', $withLaravel);
$update = new \Nexus\Install\Update();
$currentStep = $update->currentStep();
@@ -250,7 +256,7 @@ if ($currentStep == 4) {
</div>
</div>
<div class="m-10 text-center">
欢迎使用 NexusPHP 升级程序(v1.5 ~ v1.6),如有疑问,点击<a href="http://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取帮助。
欢迎使用 NexusPHP 升级程序,如有疑问,点击<a href="https://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取帮助。
</div>
</body>
<script>