12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\admin\validate;
- use think\Validate;
- class ClientManageBlock extends Validate
- {
- /**
- * 验证规则
- */
- protected $rule = [
- 'name' => 'require|max:10|checkExists',
- ];
- /**
- * 提示消息
- */
- protected $message = [
- ];
- /**
- * 验证场景
- */
- protected $scene = [
- 'add' => ['name'],
- 'edit' => ['name'],
- ];
- /**
- * 检查是否存在
- * @param $value
- * @return bool
- */
- protected function checkExists($value, $rule, $data)
- {
- $typehasdata = model('ClientManageBlock')->get(['name' => $value, 'page_id' => $data['page_id']]);
- if ($typehasdata ) {
- return '主标题重复';
- }
- return true;
- }
- }
|