Category.php 750 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. /**
  5. * 分类模型
  6. */
  7. class Category extends Model
  8. {
  9. // 开启自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'int';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. protected $updateTime = 'updatetime';
  14. public function catelist()
  15. {
  16. return $this->hasMany('Category','pid','id')->where('status','normal')->field('id,name,pid,image')->order('weigh desc,id desc');
  17. }
  18. public function getImageAttr($value)
  19. {
  20. // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
  21. if (!empty($value)){
  22. return config('site.siteUrl').$value;
  23. }else{
  24. return $value;
  25. }
  26. }
  27. }