'require', 'custom_id' => 'require|checkCustom', 'name' => 'require', 'phone' => 'mobile|unique:'.CustomContacts::class, 'email' => 'email', 'annex' => 'checkAnnex', ]; protected $message = [ 'id.require' => '缺少必要参数', 'custom_id.require' => '请选择客户', 'name.require' => '请填写姓名', 'phone.mobile' => '手机号码格式错误', 'phone.unique' => '手机号码已存在', 'email.email' => '邮箱格式错误', ]; /** * @notes 添加场景 * @return CustomContactsValidate * @author likeadmin * @date 2023/11/11 22:56 */ public function sceneAdd() { return $this->remove('id',true); } /** * @notes 编辑场景 * @return CustomContactsValidate * @author likeadmin * @date 2023/11/11 22:56 */ public function sceneEdit() {} /** * @notes 删除场景 * @return CustomContactsValidate * @author likeadmin * @date 2023/11/11 22:56 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return CustomContactsValidate * @author likeadmin * @date 2023/11/11 22:56 */ 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 checkAnnex($value): bool|string { if(!empty($value) && $value != ''){ if(!is_array($value)){ return '附件格式错误'; } } return true; } }