'require', 'name' => 'require', 'custom_id' => 'require|checkCustom', 'date' => 'require|dateFormat:Y-m-d', 'types' => 'require|checkTypes', 'next_follow_date' => 'dateFormat:Y-m-d|checkNext', 'annex' => 'checkAnnex', ]; protected $field = [ 'id' => '数据id', 'name' => '主题', 'custom_id' => '客户id', 'date' => '日期', 'types' => '类型', 'next_follow_date' => '下次回访日期', ]; /** * @notes 添加场景 * @return CustomFollowValidate * @author likeadmin * @date 2023/11/12 13:40 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return CustomFollowValidate * @author likeadmin * @date 2023/11/12 13:40 */ public function sceneEdit() { } /** * @notes 删除场景 * @return CustomFollowValidate * @author likeadmin * @date 2023/11/12 13:40 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return CustomFollowValidate * @author likeadmin * @date 2023/11/12 13:40 */ public function sceneDetail() { return $this->only(['id']); } public function checkCustom($value): bool|string { $custom = Custom::where('id', $value)->findOrEmpty(); if ($custom->isEmpty()) { return '客户信息不存在'; } return true; } public function checkTypes($value): bool|string { $dictData = DictData::where('type_value', 'custom_follow_type')->column('value'); if (!in_array($value, $dictData)) { return '类型无效'; } return true; } public function checkNext($value, $rule, $data): bool|string { if (!empty($value)) { if (strtotime($value) - strtotime($data['date']) <= 0) { return '下次回访日期不能小于上面选择的日期'; } } return true; } }