From 78d73ed442c2cb47e2f9590c2a8167138f198bb0 Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 26 Jul 2021 18:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=91=E7=9A=84=E9=A2=91?= =?UTF-8?q?=E9=81=93=E7=BC=96=E8=BE=91=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UserChannelController.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/UserChannelController.php b/app/Http/Controllers/Api/UserChannelController.php index bb375a6..0c29275 100644 --- a/app/Http/Controllers/Api/UserChannelController.php +++ b/app/Http/Controllers/Api/UserChannelController.php @@ -9,15 +9,17 @@ class UserChannelController extends Controller // 我的频道编辑 public function update() { - $formData = request()->only('channels'); - $channels = array_filter(json_decode($formData['channels'], true)); - if (!$channels) { - return $this->error('未选择任何频道'); - } + $channels = request()->input('channels'); + $channels = json_decode($channels, true); + if (!$channels) { + return $this->error('未选择任何频道'); + } + $channels = array_unique(array_filter($channels)); $UserChannel = UserChannel::where('user_id', $this->user_id)->first(); $UserChannel->channels = $channels; $UserChannel->save(); + return $this->success(); } }