29 lines
725 B
PHP
29 lines
725 B
PHP
<?php
|
|
/**
|
|
* @copyright Copyright (c) 2021 勾股工作室
|
|
* @license https://opensource.org/licenses/Apache-2.0
|
|
* @link https://www.gougucms.com
|
|
*/
|
|
|
|
namespace app\admin\validate;
|
|
use think\Validate;
|
|
use think\facade\Db;
|
|
|
|
class ArticleCateValidate extends Validate
|
|
{
|
|
// 自定义验证规则
|
|
protected function checkOne($value,$rule,$data=[])
|
|
{
|
|
$count = Db::name('ArticleCate')->where([['title','=',$data['title']],['id','<>',$data['id']],['delete_time','=',0]])->count();
|
|
return $count == 0 ? true : false;
|
|
}
|
|
|
|
protected $rule = [
|
|
'title' => 'require|checkOne',
|
|
];
|
|
|
|
protected $message = [
|
|
'title.require' => '分类名称不能为空',
|
|
'title.checkOne' => '同样的分类名称已经存在',
|
|
];
|
|
} |