Ordertest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Ordertest extends Model{
  5. protected $table='order_all';
  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_gift_infos(){
  14. return $this->belongsToMany(Gift::class,OrderGift::class,'order_id','gift_id')->withPivot('num');
  15. }
  16. public function get_user(){
  17. return $this->belongsTo(User::class,'user_id');
  18. }
  19. public function get_gift(){
  20. return $this->hasMany(OrderGift::class,'order_id','id');
  21. }
  22. public function get_log(){
  23. return $this->hasMany(Orderlog::class,'order_id','id');
  24. }
  25. public function address(){
  26. return $this->belongsTo(Address::class,'address_id');
  27. }
  28. public function get_address(){
  29. return $this->belongsToMany(User::class,Address::class,'id','mobile','address_id','mobile')->whereIn('cert_status',[3,6]);
  30. }
  31. /**获取物流信息**/
  32. public function get_express(){
  33. return $this->hasMany(Express::class,'order_id');
  34. }
  35. public function belong_user(){
  36. return $this->belongsTo(User::class,'good_user_id');
  37. }
  38. }