<?php namespace app\common\model; use think\Model; class ArticleCategory extends Model { // 表名 protected $name = 'article_category'; // 自动写入时间戳字段 protected $autoWriteTimestamp = 'int'; // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = false; protected $deleteTime = false; // 追加属性 protected $append = [ 'status_text', 'hidden_text' ]; public function getStatusList() { return ['0' => __('Status 0'), '1' => __('Status 1')]; } public function getHiddenList() { return ['0' => __('Hidden 0'), '1' => __('Hidden 1')]; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getHiddenTextAttr($value, $data) { $value = $value ? $value : (isset($data['hidden']) ? $data['hidden'] : ''); $list = $this->getHiddenList(); return isset($list[$value]) ? $list[$value] : ''; } public static function lst($where) { $model = new self; $model =$model->where('hidden',0)->where('status',1); if(isset($where['cid']) && $where['cid']>0) $model->where('cid',$where['cid']); if(isset($where['pid']) && $where['pid']>0) $model->where('pid',$where['pid']); return $model->order("sort desc,id asc")->select(); } }