'require|checkData', 'budget_doc_id' => 'require|checkBudgetDoc', 'dept_id' => 'require|checkDept', 'type' => 'require|checkType', 'amount' => 'require|float|gt:0', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'budget_doc_id' => '预算书id', 'dept_id' => '部门', 'type' => '预算分成方式', 'amount' => '预算分成金额', 'remark' => '备注', ]; /** * @notes 添加场景 * @return FinancialBudgetDocDetailValidate * @author likeadmin * @date 2024/03/26 13:54 */ public function sceneAdd() { return $this->only(['budget_doc_id', 'dept_id', 'type', 'amount', 'remark']); } /** * @notes 编辑场景 * @return FinancialBudgetDocDetailValidate * @author likeadmin * @date 2024/03/26 13:54 */ public function sceneEdit() { return $this->only(['id', 'budget_doc_id', 'dept_id', 'type', 'amount', 'remark']); } /** * @notes 删除场景 * @return FinancialBudgetDocDetailValidate * @author likeadmin * @date 2024/03/26 13:54 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return FinancialBudgetDocDetailValidate * @author likeadmin * @date 2024/03/26 13:54 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = FinancialBudgetDocDetail::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '数据不存在' : true; } public function checkBudgetDoc($value): bool|string { $data = FinancialBudgetDoc::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '项目预算书信息不存在' : true; } public function checkDept($value): bool|string { $data = Dept::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '部门信息不存在' : true; } public function checkType($value): bool|string { $dict = DictData::where('type_value', 'budget_share_method')->column('value'); return !in_array($value, $dict) ? '预算分成方式数据值无效' : true; } }