Browse Source

修改我的频道编辑的BUG

dev
李可松 5 years ago
parent
commit
78d73ed442
  1. 12
      app/Http/Controllers/Api/UserChannelController.php

12
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();
}
}
Loading…
Cancel
Save