| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * 广告
- * @author wesmielr
- */
- namespace app\index\service;
- use think\Db;
- class AdvertService
- {
- /**
- * 获取对应位置轮播列表
- * @param $slideId 广告位ID
- * @param int $num 获取数量
- * @param string $field 字段
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getListBySlide($slideId, $num=6, $field=''){
- $field = $field? $field : 'id,title,image,url,target';
- return Db::name('slide_item')->where(['status'=> 1])
- ->where(function($query) use ($slideId){
- if(is_array($slideId)){
- $query->whereIn('slide_id', $slideId);
- }else{
- $query->where('slide_id', $slideId);
- }
- })
- ->field($field)
- ->order('list_order')
- ->limit($num)
- ->select()
- ->toArray();
- }
- }
|