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.
		
		
		
		
		
			
		
			
				
					
					
						
							33 lines
						
					
					
						
							907 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							33 lines
						
					
					
						
							907 B
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Http\Controllers\Api;
							 | 
						|
								use App\Http\Controllers\Controller;
							 | 
						|
								use App\Models\AgentProduct;
							 | 
						|
								use App\Models\Special;
							 | 
						|
								use Illuminate\Support\Facades\Storage;
							 | 
						|
								
							 | 
						|
								class SpecialController extends Controller
							 | 
						|
								{
							 | 
						|
									//专题产品列表
							 | 
						|
									public function show()
							 | 
						|
									{
							 | 
						|
										$id = (int)request()->input('id');
							 | 
						|
										$prefix = Storage::disk('public')->url('');
							 | 
						|
								
							 | 
						|
										$detail = Special::query()
							 | 
						|
											->select(['id', 'picture', 'updated_at', 'agent_product_id'])
							 | 
						|
											->find($id);
							 | 
						|
										$detail->picture = array_map(fn($v) => $prefix . $v, $detail->picture);
							 | 
						|
								
							 | 
						|
										$detail->product = AgentProduct::list()
							 | 
						|
											->where('agent_id', $this->agent_id)
							 | 
						|
											->whereIn('id', $detail->agent_product_id)
							 | 
						|
											->orderBy('id', 'DESC')->limit(6)->get();
							 | 
						|
										foreach ($detail->product as $k => &$v) {
							 | 
						|
											$v->pictures = array_map(fn($item) => $prefix . $item, $v->pictures);
							 | 
						|
										}
							 | 
						|
										unset($detail->agent_product_id);
							 | 
						|
								
							 | 
						|
										return $this->success($detail);
							 | 
						|
									}
							 | 
						|
								}
							 |