TaxiOrder.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\common\model;
  3. class TaxiOrder extends BaseModel
  4. {
  5. /**
  6. * @var string
  7. */
  8. protected $name = 'taxi_order';
  9. /**
  10. * @var array
  11. */
  12. protected $auto = [];
  13. /**
  14. * @var array
  15. */
  16. protected $insert = ['created_at','updated_at','dispense_at'];
  17. /**
  18. * @var array
  19. */
  20. protected $update = ['updated_at'];
  21. public function setDispenseAtAttr()
  22. {
  23. return time();
  24. }
  25. /**
  26. * @param $value
  27. * @return false|string
  28. */
  29. public function getCreatedAtAttr($value)
  30. {
  31. return ['val'=>$value,'text'=>date('m.d H:i', $value)];
  32. }
  33. /**
  34. * 关联车俩
  35. * @return \think\model\relation\BelongsTo
  36. */
  37. public function user()
  38. {
  39. return $this->belongsTo('Users','user_id','id');
  40. }
  41. /**
  42. * 关联车辆司机
  43. * @return \think\model\relation\BelongsTo
  44. */
  45. public function taxiUser()
  46. {
  47. return $this->belongsTo('TaxiUser','taxi_uid','id');
  48. }
  49. /**
  50. * 关联车俩
  51. * @return \think\model\relation\BelongsTo
  52. */
  53. public function taxi()
  54. {
  55. return $this->belongsTo('Taxi','taxi_id','id');
  56. }
  57. /**
  58. * 关联支付订单
  59. * @return \think\model\relation\BelongsTo
  60. */
  61. public function paylog()
  62. {
  63. return $this->belongsTo('OrderPaylog','id', 'order_idx')
  64. ->field('order_idx,out_trade_no,total_price,pay_type')
  65. ->where('is_pay', 1);
  66. }
  67. public function category()
  68. {
  69. return $this->belongsTo('\app\common\model\TaxiServiceCategory', 'category_id')
  70. ->field('id,name,color');
  71. }
  72. }