OrderEffectiveLog.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. protected $type = [
  14. 'effective_images' => 'array',
  15. ];
  16. public function goods()
  17. {
  18. return $this->hasOne(Goods::class, 'id', 'goods_id');
  19. }
  20. public function originalServiceWork()
  21. {
  22. return $this->hasOne(ServiceWork::class, 'id', 'work_id');
  23. }
  24. public function serviceWork()
  25. {
  26. return $this->hasOne(ServiceWork::class, 'order_effective_id', 'id');
  27. }
  28. public function getEndEffectiveTimeAttr($value,$data)
  29. {
  30. return !empty($data['end_effective_time'])?date('Y-m-d H:i:s',$data['end_effective_time']):'';
  31. }
  32. public static function getEffectiveUnitTextAttr($value,$data)
  33. {
  34. $type = [1 => '天',2=> '小时'];
  35. return $type[$data['effective_unit']];
  36. }
  37. }