From d32d72ec64dd849327b533b149de6798fe34d978 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Thu, 30 Jun 2022 18:00:34 +0800 Subject: [PATCH] update status --- .../Http/Controllers/PluginController.php | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/beike/Admin/Http/Controllers/PluginController.php b/beike/Admin/Http/Controllers/PluginController.php index dd2bae5b..fab2fbf7 100644 --- a/beike/Admin/Http/Controllers/PluginController.php +++ b/beike/Admin/Http/Controllers/PluginController.php @@ -11,14 +11,16 @@ namespace Beike\Admin\Http\Controllers; +use Exception; use Beike\Plugin\Manager; -use Beike\Repositories\SettingRepo; use Illuminate\Http\Request; +use Beike\Repositories\SettingRepo; +use Illuminate\Contracts\View\View; class PluginController extends Controller { /** - * @throws \Exception + * @throws Exception */ public function index() { @@ -30,9 +32,10 @@ class PluginController extends Controller /** * @param Request $request * @param $code - * @throws \Exception + * @return View + * @throws Exception */ - public function edit(Request $request, $code) + public function edit(Request $request, $code): View { $data['plugin'] = (new Manager)->getPlugin($code); return view('admin::pages.plugins.form', $data); @@ -43,13 +46,13 @@ class PluginController extends Controller * @param Request $request * @param $code * @return array - * @throws \Exception + * @throws Exception */ public function update(Request $request, $code): array { $plugin = (new Manager)->getPlugin($code); if (empty($plugin)) { - throw new \Exception("无效的插件"); + throw new Exception("无效的插件"); } $fields = $request->all(); SettingRepo::update('plugin', $code, $fields); @@ -60,11 +63,17 @@ class PluginController extends Controller /** * @param Request $request * @param $code - * @throws \Exception + * @return array + * @throws Exception */ - public function updateStatus(Request $request, $code) + public function updateStatus(Request $request, $code): array { $plugin = (new Manager)->getPlugin($code); - dd($plugin); + if (empty($plugin)) { + throw new Exception("无效的插件"); + } + $status = $request->get('status'); + SettingRepo::update('plugin', $code, ['name' => 'status', 'value' => $status]); + return json_success("编辑成功"); } }