| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\model; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Slide extends Base | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-12-02 18:34:44 +08:00
										 |  |  |     public const homePosition = "home-banner"; | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  |     public static function delByIds($ids) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return self::whereIn('id', $ids)->delete(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //获取幻灯片列表
 | 
					
						
							|  |  |  |     public static function getList() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return self::order("sort asc") | 
					
						
							|  |  |  |             ->select() | 
					
						
							|  |  |  |             ->toArray(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public static function onAfterInsert($slide) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $slide->sort = $slide->id; | 
					
						
							|  |  |  |         $slide->save(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //获取轮播图涉及到的文件
 | 
					
						
							|  |  |  |     public static function getFilesInUse() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $items = self::select()->toArray(); | 
					
						
							|  |  |  |         $data  = []; | 
					
						
							|  |  |  |         foreach ($items as $item) { | 
					
						
							|  |  |  |             $src = trim($item['src']); | 
					
						
							|  |  |  |             if (!empty($src)) { | 
					
						
							|  |  |  |                 $key        = getKeyByPath($src); | 
					
						
							|  |  |  |                 $data[$key] = $src; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return $data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |