Ordertest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Ordertest extends Model{
  5. protected $table='order_test';
  6. public function order_detail(){
  7. return $this->hasMany(OrderDetail::class,'order_id');
  8. }
  9. public function order_details(){
  10. return $this->hasManyThrough(Goodtest::class,OrderDetail::class,'order_id','id','id','goods_id');
  11. }
  12. public function get_user(){
  13. return $this->belongsTo(User::class,'user_id');
  14. }
  15. public function get_log(){
  16. return $this->hasMany(Orderlog::class,'order_id','id');
  17. }
  18. public function address(){
  19. return $this->belongsTo(Address::class,'address_id');
  20. }
  21. public function get_address(){
  22. return $this->belongsToMany(User::class,Address::class,'id','mobile','address_id','mobile')->whereIn('cert_status',[3,6]);
  23. }
  24. /**获取赠品**/
  25. public function get_gift(){
  26. return $this->hasMany(OrderGift::class,'order_id','id');
  27. }
  28. /**赠品名称**/
  29. public function get_gift_info(){
  30. return $this->hasManyThrough(Gift::class,OrderGift::class,'order_id','id','id','gift_id');
  31. }
  32. public function get_gift_infos(){
  33. return $this->belongsToMany(Gift::class,OrderGift::class,'order_id','gift_id')->withPivot('num');
  34. }
  35. /**获取物流信息**/
  36. public function get_express(){
  37. return $this->hasMany(Express::class,'order_id');
  38. }
  39. public function get_pay(){
  40. return $this->hasMany(UserPay::class,'order_num','order_num');
  41. }
  42. public function belong_user(){
  43. return $this->belongsTo(User::class,'good_user_id');
  44. }
  45. }