Ordertest.php 1.6 KB

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