OwnerPriceOperation.php 1.2 KB

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