luck-draw/app/model/Slide.php

41 lines
850 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;
}
}
return $data;
}
}