OwnerPriceOperation.php 1.1 KB

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