50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
| <?php
 | |
| namespace app\model;
 | |
| 
 | |
| class Link extends Base
 | |
| {
 | |
|     public static function delByIds($ids)
 | |
|     {
 | |
|         return self::whereIn('id', $ids)->delete();
 | |
|     }
 | |
|     
 | |
|     //获取友情链接
 | |
|     public static function getList()
 | |
|     {
 | |
|         return self::order('sort desc')
 | |
|         ->select()
 | |
|         ->toArray();
 | |
|     }
 | |
| 
 | |
|     public static function onAfterInsert($item)
 | |
|     {
 | |
|         $item->sort  = $item->id;
 | |
|         $item->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;
 | |
|     }
 | |
|     public static function getListNew($limit = 5){
 | |
|         return self::order('sort desc')
 | |
|             ->limit($limit)
 | |
|             ->select()
 | |
|             ->toArray();
 | |
|     }
 | |
|     public static function getListPage($limit = 5){
 | |
|         return self::order("sort desc")
 | |
|             ->paginate($limit, false);
 | |
|     }
 | |
| }
 |