OwnerPriceOperation.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class OwnerPriceOperation extends Model
  5. {
  6. protected $fillable = [
  7. "operation_type", //操作类型
  8. "name", //名称
  9. "strategy", //策略
  10. "feature", //特征
  11. "remark", //备注
  12. "priority", //优先级 值越大越高
  13. ];
  14. public static $features = null;
  15. public static $columnMapping = null;
  16. public function ownerInStorageRule()
  17. { //入库规则
  18. return $this->hasOne(OwnerInStorageRule::class,"owner_price_operation_id","id");
  19. }
  20. public function ownerOutStorageRules()
  21. { //出库规则
  22. return $this->hasMany(OwnerOutStorageRule::class,"owner_price_operation_id","id");
  23. }
  24. public function ownerPriceOperationOwners()
  25. { //货主中间表
  26. return $this->belongsToMany(Owner::class,"owner_price_operation_owner","owner_price_operation_id","owner_id");
  27. }
  28. public function getFeatureFormatAttribute()
  29. {
  30. if ($this->strategy == '默认')return "/";
  31. return app("FeatureService")->formatFeature(self::$features,$this->feature,self::$columnMapping);
  32. }
  33. }