Ordertest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Ordertest extends Model
  5. {
  6. protected $table='order_test';
  7. public function get_user(){
  8. return $this->belongsTo(User::class,'user_id')->withTrashed();
  9. }
  10. public function get_order_detail(){
  11. return $this->hasMany(Orderdetail::class,'order_id','id');
  12. }
  13. public function get_address(){
  14. return $this->belongsTo(Address::class,'address_id','id');
  15. }
  16. public function get_order_log(){
  17. return $this->hasMany(Orderlog::class,'order_id','id');
  18. }
  19. public function get_order_gift()
  20. {
  21. return $this->belongsToMany('App\Models\Gifts','order_gift','order_id','gift_id')->withPivot('num');
  22. }
  23. public function get_order_remark(){
  24. return $this->hasMany(OrderRemark::class,'order_id','id');
  25. }
  26. public function get_store(){
  27. return $this->belongsTo(Store::class,'store_id');
  28. }
  29. public function get_order_good()
  30. {
  31. return $this->belongsToMany(Goodtest::class,'order_detail','order_id','goods_id')->withPivot('num');
  32. }
  33. public function belong_user(){
  34. return $this->belongsTo(User::class,'good_user_id')->withTrashed();
  35. }
  36. }