1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace app\api\model;
- use think\Model;
- /**
- * 分类模型
- */
- class Category extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public function catelist()
- {
- return $this->hasMany('Category','pid','id')->where('status','normal')->field('id,name,pid,image')->order('weigh desc,id desc');
- }
- public function getImageAttr($value)
- {
- // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
- if (!empty($value)){
- return config('site.siteUrl').$value;
- }else{
- return $value;
- }
- }
- }
|