- 添加 Dockerfile 与多套 docker-compose 配置(开发/生产环境) - 集成 Laravel Octane (Swoole) 提升性能 - 新增健康检查、监控脚本及部署文档 - 新增 Docker 镜像离线导入包(MySQL/Redis/Meilisearch) - 优化文档转换、预览服务及队列任务 - 添加 CreateAdminUser 命令与路由健康检查接口 - 新增 Swoole 队列兼容性测试套件 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class CreateAdminUser extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'admin:create {email} {password} {--name=系统管理员}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = '创建管理员用户';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$email = $this->argument('email');
|
|
$password = $this->argument('password');
|
|
$name = $this->option('name');
|
|
|
|
// 检查用户是否已存在
|
|
if (User::where('email', $email)->exists()) {
|
|
$this->error("用户 {$email} 已存在!");
|
|
return 1;
|
|
}
|
|
|
|
// 创建管理员用户
|
|
$admin = User::create([
|
|
'name' => $name,
|
|
'email' => $email,
|
|
'password' => Hash::make($password),
|
|
'email_verified_at' => now(),
|
|
]);
|
|
|
|
$this->info("管理员用户创建成功!");
|
|
$this->info("姓名: {$admin->name}");
|
|
$this->info("邮箱: {$admin->email}");
|
|
$this->info("密码: {$password}");
|
|
|
|
return 0;
|
|
}
|
|
} |