12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\model;
- use think\Model;
- class Ads extends Model
- {
- // 表名
- protected $name = 'ads';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text'
- ];
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- /**
- * 获取轮播
- * @param $cid
- * @return bool|\PDOStatement|string|\think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function getbanner($cid,$limit=5)
- {
- $rs = self::where('cid',$cid)->where('category_id',27)->where('status',1)->limit(0,$limit)->order('sort desc,id asc')->select();
- return $rs;
- }
- }
|