| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -2,6 +2,7 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					namespace App\Models; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\ProductStatus; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Database\Eloquent\Factories\HasFactory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Database\Eloquent\SoftDeletes; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -64,4 +65,16 @@ class AgentProduct extends BaseModel | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$this->attributes['product_ids'] = join(',', array_filter($value)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						//列表查询统一查询条件
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function scopeList($query) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return $query->with('product:id,title,pictures') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->whereHas('product', function ($query) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									return $query->where('status', ProductStatus::ON_SALE)->where('stock', '>', 0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->where('status', ProductStatus::ON_SALE)->where('stock', '>', 0) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->select('id', 'sale', 'product_id', 'price', 'original_price') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->orderBy('id', 'DESC'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |