TaxiOrder.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * 关联车俩
  27. * @return \think\model\relation\BelongsTo
  28. */
  29. public function user()
  30. {
  31. return $this->belongsTo('Users','user_id','id');
  32. }
  33. /**
  34. * 关联车俩
  35. * @return \think\model\relation\BelongsTo
  36. */
  37. public function taxi()
  38. {
  39. return $this->belongsTo('Taxi','taxi_id','id')->with(['user']);
  40. }
  41. /**
  42. * 关联支付订单
  43. * @return \think\model\relation\BelongsTo
  44. */
  45. public function paylog()
  46. {
  47. return $this->belongsTo('OrderPaylog','id', 'order_idx')
  48. ->field('order_idx,out_trade_no,total_price,pay_type')
  49. ->where('is_pay', 1);
  50. }
  51. public function category()
  52. {
  53. return $this->belongsTo('\app\common\model\TaxiServiceCategory', 'category_id')
  54. ->field('id,name,color');
  55. }
  56. }