Equipment.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Exception;
  4. use think\Model;
  5. use traits\model\SoftDelete;
  6. /**
  7. *设备表
  8. */
  9. class Equipment extends Model
  10. {
  11. use SoftDelete;
  12. protected $name = 'qingdongams_equipment';
  13. // 开启自动写入时间戳字段
  14. protected $autoWriteTimestamp = 'int';
  15. // 定义时间戳字段名
  16. protected $createTime = 'createtime';
  17. protected $updateTime = 'updatetime';
  18. protected $deleteTime = 'deletetime';
  19. public function customerProduct()
  20. {
  21. return $this->hasOne(CustomerProduct::class, 'id', 'cus_pro_id')->field('id,customer_id,status,pay_date');
  22. }
  23. public function getImgAttr($value)
  24. {
  25. if ($value) {
  26. return cdnurl(File::getUrl($value), true);
  27. } else {
  28. return $value;
  29. }
  30. }
  31. public function product()
  32. {
  33. return $this->hasOne(Product::class, 'id', 'pro_id')->field('id,name,num,img,unit,price,description');
  34. }
  35. }