Files.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * 附件管理模型
  4. */
  5. namespace app\model;
  6. use laytp\BaseModel;
  7. use think\model\concern\SoftDelete;
  8. use laytp\library\UploadDomain;
  9. class Files extends BaseModel
  10. {
  11. use SoftDelete;
  12. //模型名
  13. protected $name = 'files';
  14. //时间戳字段转换
  15. //表名
  16. //关联模型
  17. public function category(){
  18. return $this->belongsTo('app\model\files\Category','category_id','id');
  19. }
  20. public function createAdminUser(){
  21. return $this->belongsTo('app\model\admin\User','create_admin_user_id','id');
  22. }
  23. public function updateAdminUser(){
  24. return $this->belongsTo('app\model\admin\User','update_admin_user_id','id');
  25. }
  26. //新增属性的方法
  27. public function getPathAttr($value, $data)
  28. {
  29. return $value ? UploadDomain::singleAddUploadDomain($data) : '';
  30. }
  31. public function getCreateTimeIntAttr($value, $data)
  32. {
  33. return isset($data['create_time']) ? strtotime($data['create_time']) : 0;
  34. }
  35. public function getUpdateTimeIntAttr($value, $data)
  36. {
  37. return isset($data['update_time']) ? strtotime($data['update_time']) : 0;
  38. }
  39. public function getDeleteTimeIntAttr($value, $data)
  40. {
  41. return isset($data['delete_time']) ? strtotime($data['delete_time']) : 0;
  42. }
  43. }