40 lines
829 B
PHP
40 lines
829 B
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 asc')
|
||
|
->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;
|
||
|
}
|
||
|
}
|