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.

36 lines
859 B

  1. <?php
  2. namespace App\Model\v3;
  3. use App\Model\Model;
  4. class OrderMain extends Model
  5. {
  6. protected $table = 'lanzu_order_main';
  7. protected $appends = [
  8. 'created_at_text'
  9. ];
  10. public function getCreatedAtTextAttribute()
  11. {
  12. return date('Y-m-d H:i:s', $this->attributes['created_at']);
  13. }
  14. public function market()
  15. {
  16. return $this->belongsTo(Market::class, 'market_id', 'id');
  17. }
  18. public function orderGoods()
  19. {
  20. // firstKey是中间表联当前表的列,secondKey是远程表对应中间表的列,localKey是当前表关联中间表的列,secondLocalKey是中间表关联远程表的列
  21. return $this->hasManyThrough(
  22. OrderGoods::class,
  23. Order::class,
  24. 'order_main_id',
  25. 'order_id',
  26. 'id',
  27. 'id'
  28. );
  29. }
  30. }