'require', 'project_id' => 'require|checkProject', 'customer_demand_id' => 'require|checkCustomerDemand', 'theme' => 'require', 'submission_time' => 'require|dateFormat:Y-m-d', 'annex' => 'checkAnnex', ]; protected $message = [ 'id.require' => '缺少必要参数', 'project_id.require' => '请选择项目', 'customer_demand_id.require' => '请选择客户需求', 'theme.require' => '请填写需求主题', 'submission_time.require' => '请选择提交时间', 'submission_time.dateFormat' => '提交时间数据格式错误', ]; /** * @notes 添加场景 * @return CustomerDemandSolutionValidate * @author likeadmin * @date 2023/11/24 21:32 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return CustomerDemandSolutionValidate * @author likeadmin * @date 2023/11/24 21:32 */ public function sceneEdit() { } /** * @notes 删除场景 * @return CustomerDemandSolutionValidate * @author likeadmin * @date 2023/11/24 21:32 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return CustomerDemandSolutionValidate * @author likeadmin * @date 2023/11/24 21:32 */ public function sceneDetail() { return $this->only(['id']); } public function checkProject($value): bool|string { $project = Project::where('id', $value)->findOrEmpty(); if ($project->isEmpty()) { return '项目不存在'; } return true; } public function checkCustomerDemand($value, $rule, $data): bool|string { $customDemand = CustomerDemand::where('id', $value)->findOrEmpty(); if ($customDemand->isEmpty()) { return '客户需求不存在'; } if ($customDemand['project_id'] != $data['project_id']) { return '客户需求与项目信息不一致'; } return true; } }