ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
<?php namespace app\admin\validate; use think\Validate; class Cate extends Validate { protected $rule=[ 'catename'=>'unique:cate|require|max:25', ]; protected $message=[ 'catename.require'=>'栏目名称不得为空!', 'catename.unique'=>'栏目名称不得重复!', ]; protected $scene=[ 'add'=>['catename'], 'edit'=>['catename'], ]; public function checkHasValue($value, $rule) { $id = input('id'); if (empty($id)) { $Value = Db::name('cate')->where('catename',$value)->find(); if (empty($Value)) { return true; } else { return "邮箱已存在!"; } } else { //更改资料判断栏目名称是否有重复 $checkValue = Db::name('cate') ->where('id','neq',$id) ->where('catename',$value) ->find(); if (empty($checkValue)) { return true; } else { return "邮箱已存在"; } } }