You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.3 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Model\v3;
  3. use App\Model\Model;
  4. class Order extends Model
  5. {
  6. protected $table = 'lanzu_order';
  7. protected $appends = [
  8. 'created_at_text',
  9. 'updated_at_text',
  10. ];
  11. protected $fillable = [
  12. 'order_main_id',
  13. 'user_id',
  14. 'store_id',
  15. 'refund_time',
  16. 'status',
  17. 'money',
  18. 'oid',
  19. 'order_num',
  20. 'refuse_refund_note',
  21. 'note',
  22. 'created_at',
  23. 'updated_at',
  24. 'deleted_at',
  25. 'refund_note',
  26. ];
  27. public function getCreatedAtTextAttribute()
  28. {
  29. return date('Y-m-d H:i:s', $this->attributes['created_at']);
  30. }
  31. public function getUpdatedAtTextAttribute()
  32. {
  33. return date('Y-m-d H:i:s', $this->attributes['updated_at']);
  34. }
  35. public function orderGoods()
  36. {
  37. return $this->hasMany(OrderGoods::class, 'order_id', 'id');
  38. }
  39. public function market()
  40. {
  41. return $this->belongsTo(Market::class, 'market_id', 'id');
  42. }
  43. public function orderMain()
  44. {
  45. return $this->belongsTo(OrderMain::class, 'order_main_id', 'global_order_id');
  46. }
  47. public function user()
  48. {
  49. return $this->belongsTo(User::class, 'user_id', 'id');
  50. }
  51. public function store()
  52. {
  53. return $this->belongsTo(Store::class, 'store_id', 'id')->withTrashed();
  54. }
  55. }