'require|checkLog', 'project_id' => 'require|checkProject', 'theme' => 'require', 'date' => 'require|dateFormat:Y-m-d', 'follow_type' => 'require|checkFollowType', 'next_follow_up_date' => 'dateFormat:Y-m-d|checkNextFollowUpDate', 'annex' => 'checkAnnex' ]; protected $message = [ 'id.require' => '缺少必要参数', 'project_id.require' => '请选择项目', 'theme.require' => '主题不能为空', 'date.require' => '日期不能为空', 'date.date' => '日期格式不正确', 'follow_type.require' => '请选择类型', 'next_follow_up_date.date' => '下次跟进时间格式不正确', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'project_id' => '项目名称', 'theme' => '主题', 'date' => '日期', ]; /** * @notes 添加场景 * @return ProjectLogsValidate * @author likeadmin * @date 2023/12/14 09:17 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return ProjectLogsValidate * @author likeadmin * @date 2023/12/14 09:17 */ public function sceneEdit() { } /** * @notes 删除场景 * @return ProjectLogsValidate * @author likeadmin * @date 2023/12/14 09:17 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return ProjectLogsValidate * @author likeadmin * @date 2023/12/14 09:17 */ public function sceneDetail() { return $this->only(['id']); } public function checkLog($value): bool|string { $data = ProjectLogs::where('id', $value)->findOrEmpty(); if ($data->isEmpty()) { return '数据不存在'; } return true; } public function checkProject($value): bool|string { $project = Project::where('id', $value)->findOrEmpty(); if ($project->isEmpty()) { return '项目不存在'; } return true; } public function checkFollowType($value): bool|string { $dictDate = DictData::where('type_value', 'follow_type')->column('value'); if (!in_array($value, $dictDate)) { return '类型不存在'; } return true; } public function checkNextFollowUpDate($value, $rule, $data): bool|string { $a = strtotime($value); $b = strtotime($data['date']); if ($a < $b) { return '下次跟进时间不能小于日志日期'; } return true; } }