ScreenTemplate.php 818 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class ScreenTemplate extends Validate{
  6. protected $rule = [
  7. 'title|名称' => 'require|length:1,50',
  8. 'name|标识' => 'require|length:1,50|unique:screen_template',
  9. // 'img|图片' => 'require',
  10. 'nums|模块数量' => 'require|gt:0',
  11. ];
  12. protected function checkContent($value,$rule,$data=[])
  13. {
  14. if(!$data['content']){
  15. return '模块绑定不能为空';
  16. }
  17. $content = json_decode($data['content'],true);
  18. if(empty($content)){
  19. return '模块绑定不能为空';
  20. }
  21. foreach ($content as $k=>$v){
  22. if($v['mid'] == 0){
  23. return '未选择模块';
  24. }
  25. }
  26. return true;
  27. }
  28. }