|
|
@@ -25,7 +25,7 @@ use app\common\validate\BaseValidate;
|
|
|
class InfoCategoryValidate extends BaseValidate
|
|
|
{
|
|
|
protected $rule = [
|
|
|
- 'id' => 'require',
|
|
|
+ 'id' => 'require|checkId',
|
|
|
'type' => 'require|in:1,2,3,4,5,6,7,8',
|
|
|
'name' => 'require|checkName',
|
|
|
'is_show' => 'in:0,1',
|
|
|
@@ -87,4 +87,14 @@ class InfoCategoryValidate extends BaseValidate
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ public function checkId($value,$rule,$data){
|
|
|
+ $where[] = ['id', '=', $value];
|
|
|
+
|
|
|
+ $result = InfoCategory::where($where)->find();
|
|
|
+ if (!$result) {
|
|
|
+ return '该分类不存在!';
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|