diff --git a/app/Console/Commands/Admin/All.php b/app/Console/Commands/Admin/All.php new file mode 100644 index 0000000..21500bb --- /dev/null +++ b/app/Console/Commands/Admin/All.php @@ -0,0 +1,43 @@ +table(['ID', '邮箱'], $admins->map(function ($admin) { + return [ + 'id' => $admin->id, + 'email' => $admin->email, + ]; + })->toArray()); + + return Command::SUCCESS; + } +} diff --git a/app/Console/Commands/CreateAdmin.php b/app/Console/Commands/Admin/Create.php similarity index 91% rename from app/Console/Commands/CreateAdmin.php rename to app/Console/Commands/Admin/Create.php index e487561..a1406c3 100644 --- a/app/Console/Commands/CreateAdmin.php +++ b/app/Console/Commands/Admin/Create.php @@ -1,19 +1,19 @@ ask('请输入管理员ID'); + + // 删除管理员 + Admin::destroy($id); + + // 输出信息 + $this->info('管理员删除成功。'); + return Command::SUCCESS; + } +} diff --git a/app/Console/Commands/Admin/Reset.php b/app/Console/Commands/Admin/Reset.php new file mode 100644 index 0000000..2a7c209 --- /dev/null +++ b/app/Console/Commands/Admin/Reset.php @@ -0,0 +1,55 @@ +ask('请输入管理员ID'); + + // 获取管理员 + $admin = Admin::find($id); + + // 验证管理员 + if (is_null($admin)) { + $this->error('管理员不存在。'); + return Command::FAILURE; + } + + // 密码 + $password = $this->secret('请输入密码'); + + $admin->password = bcrypt($password); + $admin->save(); + + // 输出信息 + $this->info('管理员密码重置成功。'); + + return Command::SUCCESS; + } +}