OrderEffectiveLog.php 865 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\model\orders;
  3. use app\common\model\BaseModel;
  4. use app\common\model\goods\Goods;
  5. use app\common\model\works\ServiceWork;
  6. /**
  7. * @author 林海涛
  8. * @date 2024/7/17 下午5:23
  9. */
  10. class OrderEffectiveLog extends BaseModel
  11. {
  12. protected $name = 'order_effective_log';
  13. public function goods()
  14. {
  15. return $this->hasOne(Goods::class, 'id', 'goods_id');
  16. }
  17. public function serviceWork()
  18. {
  19. return $this->hasOne(ServiceWork::class, 'order_effective_id', 'id');
  20. }
  21. public function getEndEffectiveTimeAttr($value,$data)
  22. {
  23. return !empty($data['end_effective_time'])?date('Y-m-d H:i:s',$data['end_effective_time']):'';
  24. }
  25. public static function getEffectiveUnitTextAttr($value,$data)
  26. {
  27. $type = [1 => '天',2=> '小时'];
  28. return $type[$data['effective_unit']];
  29. }
  30. }