You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							867 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							867 B
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Http\Controllers\Api;
							 | 
						|
								use App\Http\Controllers\Controller;
							 | 
						|
								use App\Models\UserChannel;
							 | 
						|
								use Illuminate\Http\Request;
							 | 
						|
								
							 | 
						|
								class UserChannelController extends Controller
							 | 
						|
								{
							 | 
						|
									//我的频道列表
							 | 
						|
									public function index()
							 | 
						|
									{
							 | 
						|
										$channels = UserChannel::where('user_id', $this->user_id)->value('channels');
							 | 
						|
										return $this->success($channels);
							 | 
						|
									}
							 | 
						|
								
							 | 
						|
								    // 我的频道编辑
							 | 
						|
								    public function update(Request $request)
							 | 
						|
								    {
							 | 
						|
										$formData = $request->only(['channels']);
							 | 
						|
										$request->validate([
							 | 
						|
											'channels' => 'nullable|array',
							 | 
						|
										], [
							 | 
						|
											'channels.array' => 'channels必须是数组',
							 | 
						|
										]);
							 | 
						|
								
							 | 
						|
								        $channels = array_unique(array_filter($formData['channels']));
							 | 
						|
								
							 | 
						|
								        $UserChannel = UserChannel::where('user_id', $this->user_id)->first();
							 | 
						|
								        $UserChannel->channels = $channels;
							 | 
						|
								        $UserChannel->save();
							 | 
						|
								
							 | 
						|
								        return $this->success();
							 | 
						|
								    }
							 | 
						|
								}
							 |