OwnerPriceOperationItem.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. class OwnerPriceOperationItem extends Model
  6. {
  7. use ModelLogChanging;
  8. protected $fillable = [
  9. "owner_price_operation_id", //作业计费ID
  10. "strategy", //子策略
  11. "amount", //起步数
  12. "unit_id", //单位ID
  13. "unit_price", //单价
  14. "feature", //特征
  15. "priority", //优先级 值越大越高
  16. "discount_price", //减免单价
  17. ];
  18. public $timestamps=false;
  19. public static $features = null;
  20. public static $columnMapping = null;
  21. public function unit()
  22. { //单位
  23. return $this->hasOne(Unit::class,"id","unit_id");
  24. }
  25. public function ownerPriceOperation()
  26. { //作业计费
  27. return $this->belongsTo(OwnerPriceOperation::class,"owner_price_operation_id","id");
  28. }
  29. /* 格式化依据静态参数,在调用前设置 */
  30. public function getFeatureFormatAttribute()
  31. {
  32. if ($this->strategy == '默认')return "/";
  33. return app("FeatureService")->formatFeature(self::$features,$this->feature,self::$columnMapping);
  34. }
  35. }