1, 'msg' => '{attr}必须是大于0的整数' ], // 验证土地是否属于用户 [ 'land_id', new LandOwnershipValidator($this, ['user_id', 'land']), 'msg' => '土地不存在或不属于当前用户' ], // 验证用户是否拥有该物品 [ 'item_id', new ItemOwnershipValidator($this, ['user_id', 'instance_id', 'quantity']), 'msg' => '您没有该肥料物品' ], // 验证物品是否为肥料类型 [ 'item_id', new FertilizerItemValidator($this, ['fertilizer_item', 'crop_growth_time']), 'msg' => '该物品不是有效的肥料' ], // 验证是否可以使用肥料 [ 'land_id', new FertilizerUsageValidator($this, ['land', 'crop']), 'msg' => '当前土地状态或作物生长阶段不允许使用肥料' ] ]; } /** * 设置默认值 * * @return array */ public function default(): array { return [ 'instance_id' => 0, 'quantity' => 1 ]; } }