OwnerPriceLogistic.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class OwnerPriceLogistic extends Model
  5. {
  6. protected $fillable = [
  7. "name", //名称
  8. "unit_range", //单价一区间
  9. "unit_id", //单位一ID
  10. "other_unit_range", //单位二区间
  11. "other_unit_id", //单位二ID
  12. "pick_up_price", //提货费
  13. "fuel_price", //燃油附加费
  14. "service_price", //信息服务费
  15. ];
  16. public function unit()
  17. { //单位一
  18. return $this->hasOne(Unit::class,"id","unit_id");
  19. }
  20. public function otherUnit()
  21. { //单位二
  22. return $this->hasOne(Unit::class,"id","other_unit_id");
  23. }
  24. public function owners()
  25. { //货主
  26. return $this->belongsToMany(Owner::class,"owner_price_logistic_owner","owner_price_logistic_id","owner_id");
  27. }
  28. public function logistics()
  29. { //物流
  30. return $this->belongsToMany(Logistic::class,"owner_price_logistic_logistic","owner_price_logistic_id","logistic_id");
  31. }
  32. }