| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -6,15 +6,15 @@ use App\Http\Controllers\Controller; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\AgentProduct; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\UserFav; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * 用户收藏 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * Class UserFavController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * @package App\Http\Controllers\Api | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class UserFavController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function index() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$page = request()->input('page'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($page && !ctype_digit($page)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('页码错误'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$list = UserFav::query()->with([ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'agentProduct' => fn($query) => $query->select('id', 'price', 'original_price'), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'product' => fn($query) => $query->select('id', 'title', 'pictures'), | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -28,12 +28,9 @@ class UserFavController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function create() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$id = request()->input('id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!$id || !ctype_digit($id)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('无效的ID'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$id = (int)request()->input('id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$agent_product = AgentProduct::find($id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$agent_product = AgentProduct::where('user_id', $this->user_id)->find($id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!$agent_product) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('产品不存在或已被删除'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |