其余文件
This commit is contained in:
63
app/admin/validate/community/CommunityArticleValidate.php
Normal file
63
app/admin/validate/community/CommunityArticleValidate.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate\community;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\community\CommunityArticle;
|
||||
|
||||
|
||||
/**
|
||||
* 仲裁社区文章验证
|
||||
* Class CommunityArticleValidate
|
||||
* @package app\admin\validate\community
|
||||
*/
|
||||
class CommunityArticleValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number|checkArticle',
|
||||
'status' => 'require|in:1,2',
|
||||
'audit_remark' => 'requireIf:status,2|max:100',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'id.number' => 'id必须为数字',
|
||||
'status.require' => '请选择审核状态',
|
||||
'status.in' => '审核状态值异常',
|
||||
'audit_remark.requireIf' => '请填写拒绝说明',
|
||||
'audit_remark.max' => '审核说明仅限100字内',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'audit' => ['id', 'status', 'audit_remark'],
|
||||
'id' => ['id'],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验文章
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/10 15:08
|
||||
*/
|
||||
protected function checkArticle($value, $rule, $data)
|
||||
{
|
||||
$comment = CommunityArticle::where(['del' => 0])->findOrEmpty($value);
|
||||
|
||||
if ($comment->isEmpty()) {
|
||||
return '文章信息不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
41
app/admin/validate/community/CommunityCategoryValidate.php
Normal file
41
app/admin/validate/community/CommunityCategoryValidate.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate\community;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\community\CommunityCategory;
|
||||
|
||||
/**
|
||||
* 种草社区分类验证
|
||||
* Class CommunityCategoryValidate
|
||||
* @package app\admin\validate\community
|
||||
*/
|
||||
class CommunityCategoryValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'name' => 'require|max:4|unique:'.CommunityCategory::class.',name^del',
|
||||
'is_show' => 'require|in:0,1',
|
||||
'sort' => 'egt:0'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'id.number' => 'id必须为数字',
|
||||
'name.require' => '请填写分类名称',
|
||||
'name.max' => '分类名称长度不能超过4位',
|
||||
'name.unique' => '分类名称已存在',
|
||||
'is_show.require' => '请选择是否显示',
|
||||
'is_show.in' => '选择是否显示异常',
|
||||
'sort.egt' => '请填写大于等于0的排序值',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'id' => ['id'],
|
||||
'status' => ['id', 'is_show'],
|
||||
'add' => ['name', 'is_show', 'sort'],
|
||||
'edit' => ['id', 'name', 'is_show', 'sort']
|
||||
];
|
||||
}
|
||||
60
app/admin/validate/community/CommunityCommentValidate.php
Normal file
60
app/admin/validate/community/CommunityCommentValidate.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate\community;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\community\CommunityComment;
|
||||
|
||||
|
||||
/**
|
||||
* 社区种草评论验证
|
||||
* Class CommunityCommentValidate
|
||||
* @package app\admin\validate\community
|
||||
*/
|
||||
class CommunityCommentValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number|checkComment',
|
||||
'status' => 'require|in:1,2',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'id.number' => 'id必须为数字',
|
||||
'status.require' => '请选择审核状态',
|
||||
'status.in' => '审核状态值异常',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'audit' => ['id', 'status'],
|
||||
'id' => ['id'],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验评论
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/10 15:08
|
||||
*/
|
||||
protected function checkComment($value, $rule, $data)
|
||||
{
|
||||
$comment = CommunityComment::where(['del' => 0])->findOrEmpty($value);
|
||||
|
||||
if ($comment->isEmpty()) {
|
||||
return '评论信息不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
72
app/admin/validate/community/CommunityTopicValidate.php
Normal file
72
app/admin/validate/community/CommunityTopicValidate.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate\community;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\community\CommunityTopic;
|
||||
|
||||
/**
|
||||
* 种草社区话题验证
|
||||
* Class CommunityTopicValidate
|
||||
* @package app\admin\validate\community
|
||||
*/
|
||||
class CommunityTopicValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'name' => 'require|max:12|unique:' . CommunityTopic::class . ',name^del',
|
||||
'image' => 'require',
|
||||
'cid' => 'require|number',
|
||||
'is_show' => 'require|in:0,1',
|
||||
'is_recommend' => 'require|in:0,1',
|
||||
'sort' => 'egt:0',
|
||||
'field' => 'require|checkUpdateField',
|
||||
'value' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'id.number' => 'id必须为数字',
|
||||
'name.require' => '请填写话题名称',
|
||||
'name.max' => '话题名称长度不能超过12位',
|
||||
'name.unique' => '话题名称已存在',
|
||||
'image.require' => '请选择话题图标',
|
||||
'cid.require' => '请选择关联分类',
|
||||
'is_recommend.require' => '请选择是否推荐',
|
||||
'is_recommend.in' => '推荐状态异常',
|
||||
'is_show.require' => '请选择是否显示',
|
||||
'is_show.in' => '显示状态异常',
|
||||
'sort.egt' => '请填写大于等于0的排序值',
|
||||
'field.egt' => '参数缺失',
|
||||
'value.egt' => '参数缺失',
|
||||
'value.in' => '状态值异常',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'id' => ['id'],
|
||||
'status' => ['id', 'field', 'value'],
|
||||
'add' => ['name', 'image', 'cid', 'is_recommend', 'is_show', 'sort'],
|
||||
'edit' => ['id', 'name', 'image', 'cid', 'is_recommend', 'is_show', 'sort']
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验更新字段
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/28 15:13
|
||||
*/
|
||||
protected function checkUpdateField($value, $rule, $data)
|
||||
{
|
||||
$allow_field = ['is_show', 'is_recommend'];
|
||||
if (in_array($value, $allow_field)) {
|
||||
return true;
|
||||
}
|
||||
return '非法字段';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user