diff --git a/app/Console/Commands/BackupDatabase.php b/app/Console/Commands/BackupDatabase.php index 22a3c3c..14c82ee 100644 --- a/app/Console/Commands/BackupDatabase.php +++ b/app/Console/Commands/BackupDatabase.php @@ -4,6 +4,8 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Google\Cloud\Storage\StorageClient; +use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Log; use Symfony\Component\Process\Process; class BackupDatabase extends Command @@ -85,14 +87,14 @@ class BackupDatabase extends Command ]); // 输出文件链接 - \Log::channel('backup')->info("🎉:数据库备份已上传到 Google Cloud Storage: $objectName"); + Log::channel('backup')->info("🎉:数据库备份已上传到 Google Cloud Storage: $objectName"); $this->info("🎉:数据库备份已上传到 Google Cloud Storage: $objectName"); - \File::delete($compressedBackupPath); + File::delete($compressedBackupPath); } }catch(\Exception $e){ - \Log::channel('backup')->error("😔:数据库备份失败 \n" . $e); + Log::channel('backup')->error("😔:数据库备份失败 \n" . $e); $this->error("😔:数据库备份失败\n" . $e); - \File::delete($compressedBackupPath); + File::delete($compressedBackupPath); } } } diff --git a/app/Console/Commands/ExportV2Log.php b/app/Console/Commands/ExportV2Log.php index 830ab36..ec2ccbe 100644 --- a/app/Console/Commands/ExportV2Log.php +++ b/app/Console/Commands/ExportV2Log.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Carbon\Carbon; +use Illuminate\Support\Facades\DB; class ExportV2Log extends Command { @@ -20,7 +21,7 @@ class ExportV2Log extends Command $days = $this->argument('days'); $date = Carbon::now()->subDays($days)->startOfDay(); - $logs = \DB::table('v2_log') + $logs = DB::table('v2_log') ->where('created_at', '>=', $date->timestamp) ->get(); diff --git a/app/Console/Commands/MigrateFromV2b.php b/app/Console/Commands/MigrateFromV2b.php index 5cfb013..dfa4ee2 100644 --- a/app/Console/Commands/MigrateFromV2b.php +++ b/app/Console/Commands/MigrateFromV2b.php @@ -4,6 +4,8 @@ namespace App\Console\Commands; use App\Models\Setting; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\DB; class MigrateFromV2b extends Command { @@ -132,7 +134,7 @@ class MigrateFromV2b extends Command try { foreach ($sqlCommands[$version] as $sqlCommand) { // Execute SQL command - \DB::statement($sqlCommand); + DB::statement($sqlCommand); } $this->info('1️⃣、数据库差异矫正成功'); @@ -158,7 +160,7 @@ class MigrateFromV2b extends Command public function MigrateV2ConfigToV2Settings() { - \Artisan::call('config:clear'); + Artisan::call('config:clear'); $configValue = config('v2board') ?? []; foreach ($configValue as $k => $v) { @@ -176,7 +178,7 @@ class MigrateFromV2b extends Command ]); $this->info("配置 {$k} 迁移成功"); } - \Artisan::call('config:cache'); + Artisan::call('config:cache'); $this->info('所有配置迁移完成'); } diff --git a/app/Console/Commands/XboardInstall.php b/app/Console/Commands/XboardInstall.php index c111fbb..55e8673 100644 --- a/app/Console/Commands/XboardInstall.php +++ b/app/Console/Commands/XboardInstall.php @@ -7,6 +7,10 @@ use Illuminate\Encryption\Encrypter; use App\Models\User; use App\Utils\Helper; use Illuminate\Support\Env; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\File; use function Laravel\Prompts\confirm; use function Laravel\Prompts\text; use function Laravel\Prompts\note; @@ -55,7 +59,7 @@ class XboardInstall extends Command $this->info(" / /\ \ | |_) | (_) | (_| | | | (_| | "); $this->info("/_/ \_\|____/ \___/ \__,_|_| \__,_| "); if ( - (\File::exists(base_path() . '/.env') && $this->getEnvValue('INSTALLED')) + (File::exists(base_path() . '/.env') && $this->getEnvValue('INSTALLED')) || (env('INSTALLED', false) && $isDocker) ) { $securePath = admin_setting('secure_path', admin_setting('frontend_admin_path', hash('crc32b', config('app.key')))); @@ -86,11 +90,11 @@ class XboardInstall extends Command 'DB_PASSWORD' => '', ]; try { - \Config::set("database.default", 'sqlite'); - \Config::set("database.connections.sqlite.database", base_path($envConfig['DB_DATABASE'])); - \DB::purge('sqlite'); - \DB::connection('sqlite')->getPdo(); - if (!blank(\DB::connection('sqlite')->getPdo()->query("SELECT name FROM sqlite_master WHERE type='table'")->fetchAll(\PDO::FETCH_COLUMN))) { + Config::set("database.default", 'sqlite'); + Config::set("database.connections.sqlite.database", base_path($envConfig['DB_DATABASE'])); + DB::purge('sqlite'); + DB::connection('sqlite')->getPdo(); + if (!blank(DB::connection('sqlite')->getPdo()->query("SELECT name FROM sqlite_master WHERE type='table'")->fetchAll(\PDO::FETCH_COLUMN))) { if (confirm(label: '检测到数据库中已经存在数据,是否要清空数据库以便安装新的数据?', default: false, yes: '清空', no: '退出安装')) { $this->info('正在清空数据库请稍等'); $this->call('db:wipe', ['--force' => true]); @@ -115,16 +119,16 @@ class XboardInstall extends Command 'DB_PASSWORD' => text(label: '请输入数据库密码', required: false), ]; try { - \Config::set("database.default", 'mysql'); - \Config::set("database.connections.mysql.host", $envConfig['DB_HOST']); - \Config::set("database.connections.mysql.port", $envConfig['DB_PORT']); - \Config::set("database.connections.mysql.database", $envConfig['DB_DATABASE']); - \Config::set("database.connections.mysql.username", $envConfig['DB_USERNAME']); - \Config::set("database.connections.mysql.password", $envConfig['DB_PASSWORD']); - \DB::purge('mysql'); - \DB::connection('mysql')->getPdo(); + Config::set("database.default", 'mysql'); + Config::set("database.connections.mysql.host", $envConfig['DB_HOST']); + Config::set("database.connections.mysql.port", $envConfig['DB_PORT']); + Config::set("database.connections.mysql.database", $envConfig['DB_DATABASE']); + Config::set("database.connections.mysql.username", $envConfig['DB_USERNAME']); + Config::set("database.connections.mysql.password", $envConfig['DB_PASSWORD']); + DB::purge('mysql'); + DB::connection('mysql')->getPdo(); $isMysqlValid = true; - if (!blank(\DB::connection('mysql')->select('SHOW TABLES'))) { + if (!blank(DB::connection('mysql')->select('SHOW TABLES'))) { if (confirm(label: '检测到数据库中已经存在数据,是否要清空数据库以便安装新的数据?', default: false, yes: '清空', no: '不清空')) { $this->info('正在清空数据库请稍等'); $this->call('db:wipe', ['--force' => true]); @@ -192,10 +196,10 @@ class XboardInstall extends Command $this->saveToEnv($envConfig); $this->call('config:cache'); - \Artisan::call('cache:clear'); + Artisan::call('cache:clear'); $this->info('正在导入数据库请稍等...'); - \Artisan::call("migrate", ['--force' => true]); - $this->info(\Artisan::output()); + Artisan::call("migrate", ['--force' => true]); + $this->info(Artisan::output()); $this->info('数据库导入完成'); $this->info('开始注册管理员账号'); if (!$this->registerAdmin($email, $password)) { diff --git a/database/migrations/2025_01_12_200936_modify_commission_status_in_v2_order_table.php b/database/migrations/2025_01_12_200936_modify_commission_status_in_v2_order_table.php index e1790ec..6f732c7 100644 --- a/database/migrations/2025_01_12_200936_modify_commission_status_in_v2_order_table.php +++ b/database/migrations/2025_01_12_200936_modify_commission_status_in_v2_order_table.php @@ -2,6 +2,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration diff --git a/database/migrations/2025_01_13_000000_convert_order_period_fields.php b/database/migrations/2025_01_13_000000_convert_order_period_fields.php index 907b7da..dc6718c 100644 --- a/database/migrations/2025_01_13_000000_convert_order_period_fields.php +++ b/database/migrations/2025_01_13_000000_convert_order_period_fields.php @@ -1,10 +1,8 @@ count(); if ($unconvertedCount > 0) { - \Log::warning("Found {$unconvertedCount} orders with unconverted period values"); + Log::warning("Found {$unconvertedCount} orders with unconverted period values"); } } @@ -55,4 +53,4 @@ return new class extends Migration { ->update(['period' => $oldPeriod]); } } -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/routes/channels.php b/routes/channels.php index 2bcb553..12c1b91 100755 --- a/routes/channels.php +++ b/routes/channels.php @@ -1,5 +1,8 @@