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.

60 lines
1.2 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. ];
  10. protected $fillable = [
  11. 'order_main_id',
  12. 'user_id',
  13. 'store_id',
  14. 'refund_time',
  15. 'status',
  16. 'money',
  17. 'oid',
  18. 'order_num',
  19. 'refuse_refund_note',
  20. 'note',
  21. 'created_at',
  22. 'updated_at',
  23. 'deleted_at',
  24. 'refund_note',
  25. ];
  26. public function getCreatedAtTextAttribute()
  27. {
  28. return date('Y-m-d H:i:s', $this->attributes['created_at']);
  29. }
  30. public function orderGoods()
  31. {
  32. return $this->hasMany(OrderGoods::class, 'order_id', 'id');
  33. }
  34. public function market()
  35. {
  36. return $this->belongsTo(Market::class, 'market_id', 'id');
  37. }
  38. public function orderMain()
  39. {
  40. return $this->belongsTo(OrderMain::class, 'order_main_id', 'global_order_id');
  41. }
  42. public function user()
  43. {
  44. return $this->belongsTo(User::class, 'user_id', 'id');
  45. }
  46. public function store()
  47. {
  48. return $this->belongsTo(Store::class, 'store_id', 'id');
  49. }
  50. }