OrderInfoModel.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * @description 订单列表
  7. * @author system;
  8. * @version 1.0
  9. * @date 2018-07-12 08:32:14
  10. *
  11. */
  12. class OrderInfoModel extends BaseModel
  13. {
  14. use SoftDeletes;
  15. /**
  16. * 数据表名
  17. *
  18. * @var string
  19. *
  20. */
  21. protected $table = 'order_info';
  22. /**
  23. * 主键
  24. */
  25. protected $primaryKey = 'id';
  26. //分页
  27. protected $perPage = PAGE_NUMS;
  28. /**
  29. * 可以被集体附值的表的字段
  30. *
  31. * @var string
  32. */
  33. protected $fillable = [
  34. 'out_trade_no',
  35. 'username',
  36. 'sex',
  37. 'phone',
  38. 'email',
  39. 'store_id',
  40. 'schedule_time',
  41. 'status',
  42. 'user_id',
  43. 'comment',
  44. 'product_id',
  45. 'schedule_id',
  46. 'price',
  47. 'deposit',
  48. 'paytype'
  49. ];
  50. public function store()
  51. {
  52. return (new StoreInfoModel())->find($this->store_id) ? (new StoreInfoModel())->find($this->store_id)->name : $this->store_id;
  53. }
  54. public function getstore()
  55. {
  56. return $this->belongsTo('App\Models\StoreInfoModel', 'store_id');
  57. }
  58. public function product()
  59. {
  60. return $this->belongsTo('App\Models\ProductInfoModel', 'product_id');
  61. }
  62. public function status()
  63. {
  64. switch ($this->status) {
  65. case 1:
  66. return '已付款';
  67. break;
  68. case 2:
  69. return '已完成';
  70. break;
  71. case 3:
  72. return '已取消';
  73. break;
  74. default:
  75. return '未付款';
  76. break;
  77. }
  78. }
  79. public function paidinfo()
  80. {
  81. return $this->hasOne('App\Models\PaidInfoModel', 'order_id');
  82. }
  83. public function refundinfo()
  84. {
  85. return $this->hasOne('App\Models\RefundInfoModel', 'order_id');
  86. }
  87. }