44 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			44 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								namespace app\model;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Slide extends Base
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    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;
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            $mobileSrc = trim($item['src_mobile']);
							 | 
						||
| 
								 | 
							
								            if(!empty($mobileSrc)){
							 | 
						||
| 
								 | 
							
								                $key = getKeyByPath($mobileSrc);
							 | 
						||
| 
								 | 
							
								                $data[$key] = $mobileSrc;
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        return $data;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |